Skip to content

Instantly share code, notes, and snippets.

@sphinxid
Last active August 29, 2015 14:24
Show Gist options
  • Save sphinxid/e8b46899959bc9d3382f to your computer and use it in GitHub Desktop.
Save sphinxid/e8b46899959bc9d3382f to your computer and use it in GitHub Desktop.
Javascript: Call URL before Exit from Page
window.onbeforeunload = function() {
var URL = '//preview.adskom.net/test12345.js';
var request = null;
if (window.XMLHttpRequest){
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
if (request) {
request.open("GET", URL, true);
request.send();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment