This Tutorial Has Been Viewed 22,407 Times.
This script will alert a message to the visitors before they move to another webpage or even try to cancel or close a webpage.This script confirms site exit with an alert box.
Here is the sample script.
<html>
<head>
<script type="text/JavaScript">
function ExitPage()
{
alert ('Before You Leave:\n\nPlease Check our new tutorials on http://www.mistonline.in.\n\nMore than 250 tutorials.\n\nPlease submit your own tutorials for free\n\nA complete reference for webmasters!!!!!.');
getit()
}
function getit() {
askit = confirm("Leaving so soon? Why not stay a little longer!");
if (askit == true)
alert('Thanks');
else
if (askit == false)
alert("Visit again soon!");
}
</script>
</head>
<body onbeforeunload="ExitPage();">