Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I get a popup window to open when the visitor exits the website

Status
Not open for further replies.

robert89

Technical User
Nov 19, 2003
125
CA
I have create a popup window which opens when a user enters our site (or a specific page).

Does anyone know if it is possible to have the popup come up when the user leaves the site.

Would this be done with javascript and if so, how would I go about doing this.

Any help would be appreciated.

Thanks,
Bob
 
<SCRIPT LANGUAGE = &quot;JavaScript&quot;>
<!-- //
function openit(sURL){newwindow=open(sURL,&quot;newwin&quot;,&quot;width=300, height=300&quot;);
}
//-->
</script>
</head>
<body onUnload=&quot;javascript:eek:penit ('smallwin.html')&quot;>
body text goes here
</body>

You can also change the height and width settings, or add or remove other windows settings by adding the following functions:
function openit(sURL){newwindow=open(sURL,&quot;newwin&quot;,&quot;scrollbars=no,toolbar=no,directories=no,menubar=no,resizabe=no,status=no,width=300,height=300&quot;);
}



logo.gif width='75' height='15'

bath.gif
 
Try this:

<body onunload=&quot;window.open('somePage.html')&quot;>

Adam
while(ignorance==true){perpetuate(violence,fear,hatred);life--};
 
Thank you for the unload suggestion. I kind knew about that one. I don't I was very clear in what I was asking, so I will try again.

The website has 1000s of pages. The visitor can come in through the index page and the popup will appear. However if the user jumps to a page within the site, without passing through the main index page, they will not see my popup.

Given the site has thousands of pages, I am wondering if there is anyway to have my popup appear when a clear exit has been made from the site?
 
The body tag of onUnload will do that, but you'll have to add it to every page... I'm not aware of any other way to pop open a window with javascript when someone exits a page.

~ GuidoZ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top