Forum Moderators: open

Message Too Old, No Replies

The OnUnload function

Using OnUnload for pop-up windows

         

RosscoPK

10:49 am on Jun 17, 2004 (gmt 0)

10+ Year Member



Hey Guys,

I know that this is bad etiquette in the world of HTML, but it's something that I've been asked to do for my company's website.

I know how to make a pop-up window appear when a user closes the browser, but it's when the user navigates to another page on the website or clicks the refresh button that's causing some probems. I only want the pop-up to appear when the user leaves the site completely.

From what I gather, I think I need some Javascript code that recognises whether the user is still within the boundaries of the website. However, this sounds like it could cause some security issues.

Is it possible to get around this problem? Any help would be appreciated.

DrDoc

1:46 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



We had the same question in here a while back, to which I posted a piece of code that would work. Basically, you need to set a variable to true whenever an internal link is clicked, and in your unload function check whether this variable has a value of true or not before displaying the popup.

Maybe you can find the old thread through the WebmasterWorld site search [webmasterworld.com].

DrDoc

2:00 pm on Jun 17, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I didn't find that thread... but I found another one where tedster explains the exact same thing: [webmasterworld.com...] (message 2)