samcentury
Aug 11th 2006, 5:11 am
I wan to open a popup window when user leaves d whole site or when he changes the url. I hav done it, but problem is that it displays the popup window when user clicks on browser's refresh, forward and back button and i dnt want that. Plz help me i m working on it from last morning. Below is the code
<html>
<head>
<script language="javascript" type="text/javascript">
var ex = "true";
function PopUp(x)
{
if(x==2)
{
ex="false";
}
else if (x==3 && ex=="true")
{
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
OpenWindow.document.write("<HTML><HEAD>")
OpenWindow.document.write("<TITLE>Thanks</TITLE></HEAD>")
OpenWindow.document.write("<BODY BGCOLOR=white>")
OpenWindow.document.write("Thanks to visit our site")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
self.name="main"
}
else{ex="true";}
}
</script>
</head>
<body onUnload="PopUp(3);">
<a href="sub_cat.php?maincat_id=<?=$cat_id?>" onclick="PopUp(2)" class="link" ><?=$cat_name?></a>
</body>
</html>
<html>
<head>
<script language="javascript" type="text/javascript">
var ex = "true";
function PopUp(x)
{
if(x==2)
{
ex="false";
}
else if (x==3 && ex=="true")
{
OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no");
OpenWindow.document.write("<HTML><HEAD>")
OpenWindow.document.write("<TITLE>Thanks</TITLE></HEAD>")
OpenWindow.document.write("<BODY BGCOLOR=white>")
OpenWindow.document.write("Thanks to visit our site")
OpenWindow.document.write("</BODY>")
OpenWindow.document.write("</HTML>")
OpenWindow.document.close()
self.name="main"
}
else{ex="true";}
}
</script>
</head>
<body onUnload="PopUp(3);">
<a href="sub_cat.php?maincat_id=<?=$cat_id?>" onclick="PopUp(2)" class="link" ><?=$cat_name?></a>
</body>
</html>