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!

I have been instructed by my comman

Status
Not open for further replies.

moltar

Programmer
Mar 8, 2002
26
US
I have been instructed by my commanders to create popunder windows that are only triggered when the user leaves the site (and not each time a page is unloaded). Yes, I know this is a faux pas, but while I cannot disobey an order, I did manage to at least inject some compromise and have these things display has popunders (vs. overs), and after the user leaves our site.

I've accomplished this by calling a function in the BODY tag (btw, there is only 1 file that has the BODY tag, and it is <include>'d with all pages):

<BODY onUnload=&quot;popunder()&quot;>

Here is the &quot;popunder()&quot; function in the <HEAD>:

var strMem=0
function popunder() {
if(window.name != 'exitwin' && strMem == 0) {
window.open ('window.focus();
}
}

The last component of this method is to insert the following into each link that you don't want to trigger a popunder:

<a href=&quot;pagename.asp&quot; onClick=&quot;strMem=1&quot;>

SO, this works great except for when the user hits the Back, Forward, or Refresh button on their browser.

AT LONG LAST, MY QUESTION! :

How can I have a popunder only be triggered by the user leaving the site in question, and not by any other action (including Back, Forward, and Refresh)?

Thanks!

Keith
keith@generalvitamin.com
 
Hi -

Thank you for taking your time to help me out. Unfortunately, I'm afraid that your solution didn't address what I was looking for...

I need it to be triggered only upon the user's DEPARTURE from the site. Not just once in a session, as your solution successfully accomplished, but only after EXITING THE SITE ENTIRELY.

I managed to get a solution (described above) that accomplished this functional need, but it fails when the user hits a Back, Forward, or Refresh button on their browser - the popunder is triggered by those 3 buttons and I am trying to avoid this.

I have spent hours trying to find a solution to this. If anyone can either provide an answer to me or even point me to a site that has such a setup, it would be greatly appreciated. Thanks!

moltar
aka Keith
keith@generalvitamin.com
 
Hi,

How about creating a chromless window in which to browse your website, and a button which says &quot;close website&quot;, you can then instruct the popup only to occur upon pressing this button.

James
 
To do what you're asking, you could have the popunder window check to see what window.opener.domain is, and close itself if it's still on the website. I haven't checked this method out personally, so am not sure if it'd actually work or not. The only way I can think of to accomplish what you want is to make the popunder responsible for staying open or not.
 

i got an idea...in theory...give me a minute.


- spewn
 
Hi,

As someone once said, 9 dots, connected by only 4 lines, &quot;think outside the box&quot;.

Run the website in a frame, with the frame consisting of two windows, one window is only 1px high and contains the script.

The second window, which apparentley takes up the entire window in the users view is your website.

The script is a simple one in the 1px high window that can detect if the user goes outside of your website by detecting an image change, and then you can magically do your popup.

The script I have found checks if a url has changed in a different window and if it does, it produces an error, or in your case a popup. All you have to do is convert the script to run inside a frame.

Would you like the script?

If so, Sorted.

James
 
wow! I really appreciate the efforts that is being putting into this...

I am becoming surprised at what a true puzzle this is turning out to be.

Thanks for the nifty approaches, James, they've been great! But I'm afraid that I have to stay away from the use of frames. Frames tend to cause serious issues when trying to get good search engine placement (something we find ourselves succeeding in now).

One tact that I've started to look at is &quot;session&quot; recognition, but I am beginning to wonder if this is an impossible task after all?

I've also been keeping my eye out for sites that have this desired functionality, but the ones I've noticed so far fail when the browser buttons are used (Back, Forward, Refresh) and show the popup/under.
 
Hi,

To get around the search engines, just create an plain, non-framed index page (leading too the index pages) with all the meta tags on it, in these you can tell the spiders to look further into your pages, then all you need to do is add a script to make sure that they are clicked on, it loads up the frame too.

I always like a challenge :)

James
 
Hi,

Well you can do it via cookies, if you say no to cookies, you may as well say no to javascript, both can be turned off or turned away.

The best solution would be the 1px frame (with non-framed index page) OR

Cookie OR

Toolbar and URL bar = no in a window.open OR

a popup window which is already open when the user enters the site, make it something nice, not an advert or whatever, something like &quot;the time is xx:xx:xx&quot;, they will hopefully not close this window being harmless and then when they do exit the site, you can create a simple popup.

Tell your commanders that thoose are the only options

P.S. browser sessions is no good as the popup won't occur until the session ends, that is the browser is closed.

Hope this helps

James
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top