Skip to content

Instantly share code, notes, and snippets.

@sergiosusa
Last active March 10, 2019 17:25
Show Gist options
  • Save sergiosusa/588a457787509e6bd1207309a9b5f8c9 to your computer and use it in GitHub Desktop.
Save sergiosusa/588a457787509e6bd1207309a9b5f8c9 to your computer and use it in GitHub Desktop.
/**** Url ****/
function getCurrentUrl() {
return window.location.href;
}
function getParameterByName(name, url) {
if (!url) url = window.location.href;
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}
/**** Page Options ****/
function realoadPage(miliseconds) {
return setInterval(function () {
window.location.reload();
}, miliseconds);
}
function closePage(miliseconds) {
return setInterval(function () {
window.close();
}, miliseconds);
}
/**** DOM Manipulation ****/
function insertAfter(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode.nextSibling);
}
function insertBefore(newNode, referenceNode) {
referenceNode.parentNode.insertBefore(newNode, referenceNode);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment