Forum Moderators: open

Message Too Old, No Replies

Hi all, I`m new here - Javascript question

Pop-up / Exit question

         

Paulie

11:44 pm on Dec 8, 2004 (gmt 0)

10+ Year Member



Hi everbody, I`m new here and just wanted to say that this appears an excellent resource site.

Quick question for any Javascript experts, this code launches a pop on load. Can it be adapted so it pops on exit ( page closure ).

-------
<script language="javascript">
focusid=setTimeout("focus();window.showModelessDialog('http://www.webmasterworld.com/home.htm','','scroll:1;status:0;help:0;resizable:700;dialogWidth:985px;dialogHeight:700px')",0000)
</script>
-------

Thank you!

WebChicken

12:02 pm on Dec 14, 2004 (gmt 0)

10+ Year Member



This is will pop on exit once per visit:

Put in Header:

<script src="cookiepop.js" language="JavaScript"></script>

Put in Body:

<body onunload="loadpopup()"

Make a cookie.js file with this:

function openpopup(){
window.open("http://www.yoursite.com/pop1.htm","Name of Pop","width=460,height=500")
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset!= -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function loadpopup(){
if (get_cookie('popped')==''){
openpopup()
document.cookie="popped=yes"
}
}