473,320 Members | 1,953 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

conditional popup onunload

Hi: I have a one-page salesletter website and an accompanying order page. I want a popup to appear only if the visitor leaves both pages.

In other words, I’m trying to have the popup appear only if a visitor to page A closes page A except if the visitor goes to page B (going to page B closes page A and brings up the popup, but I don’t want that yet). Then if that visitor closes page B, I want the same popup to appear unless the visitor is returning to page A.

Here’s the logic that I think would work:

Script on page A:
if leaving current page AND NOT loading page B
then popup the following window [onunload="javascript:PopupMe()"]


Script on page B:
if leaving current page AND NOT loading page A
then popup the following window [onunload="javascript:PopupMe()"]

Is there a javascript I can use to accomplish this?

Thanks!

--Gabriel
Nov 20 '06 #1
1 2667
acoder
16,027 Expert Mod 8TB
Popups are bad - consider an alternative. If someone wants to leave and you annoy them with a popup, it's not likely they'll be back.

Assuming a legitimate use for this, you can't check which website a user will go to, but if the user's using a link from one page to get to the next, you can use the onclick to set a variable (showPopup) to false. In the onunload, check if showPopup is true before showing a popup.
May 29 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Alex Shi | last post by:
Hello, I need an Exit popup page that when a visitor is on leaving my site it will popup. With "onUnLoad" it can work in this way but it also does something more that I don't want. When a...
10
by: Thad | last post by:
Any javascript I could try on this? I've got a popup window on my site with the browser chrome removed. Another site's gone ahead and done a popup to my same .html page. The visitor to that site...
22
by: Steve Horrillo | last post by:
I'm also having trouble with a popup on leave javascript. It seems that it pops up when I browse to another page instead of waiting till I completely leave my site. What am I doing wrong. Mind you,...
2
by: David W. Simmonds | last post by:
I have a popup window appear when a user clicks on a hyperlink in a datalist. I do it like this: dr = "javascript:mywindow=window.open(" + "\"GameStats.aspx?Date="+dr + "&Away="+dr + "&Home="+dr...
1
by: bblaze1 | last post by:
I know this is a frequent problem, so I apologize if this has been posted before. I have been looking online for hours to find a solution for this. I have a main order form and an "Are you Sure"...
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
1
by: bijukprm | last post by:
Hai friends, I am having a problem in my asp.net project.I have a form that has some anthem dropdowns which is data binded.I am opening a new page as popup and adding some data to the database.I...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.