I'm sure there is a very simple answer to this, but I haven't found it yet. So, here goes:
This script does a great job of ignoring internal links and not popping when someone clicks on a link to leave the page, but it still pops on close regardless of whether they previously clicked an internal link. What I would like to do, is only have it pop on exit if they have not previously clicked a link.
Can someone help me out?
Here's the code:
This script does a great job of ignoring internal links and not popping when someone clicks on a link to leave the page, but it still pops on close regardless of whether they previously clicked an internal link. What I would like to do, is only have it pop on exit if they have not previously clicked a link.
Can someone help me out?
Here's the code:
Code:
<script type="text/javascript" language="javascript">
var areYouReallySure = false;
var internalLink = false;
function areYouSure() {
if (!areYouReallySure && !internalLink) {
areYouReallySure = true;
location.href="http://your-link-goes-here"
return "*****************************************************\n\nBefore you leave this page, blah blah blah blah blah\n\nPress **CANCEL** NOW to do something more\n\n*****************************************************";
}
}
window.onbeforeunload = areYouSure;
</script>