Last active
December 22, 2015 11:59
-
-
Save sriannamalai/6469761 to your computer and use it in GitHub Desktop.
Code to open a URL upon exiting from the currently visited site in the Browser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script language="javascript"> | |
var isExit = true; | |
</script> | |
</head> | |
<body> | |
<a href="some-other-link-inside-your-site" onclick="isExit = false;">some other link inside your site</a> | |
<script language="javascript"> | |
// Open an URL as the Window is closed | |
window.onbeforeunload = function() { | |
if (isExit) window.open("http://test.com"); | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment