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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Testing the URL in an Unload event

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I am looking for a solution to perform the following treatment :
- I set an Unload="goodbye()" in the body tag of each page of my site
- I want this function to display a popup only if the next URL to be reached by the browser is out of my site (ie. not beginning by the FQDN of my site).

Has anyone a solution
 
I'd make the Goodbye popup window itself do the checking for the URL, and automatically close if it's still on the site. If it's not on the site, then it remains open.
 
Having a popup open and close wherever you go would be a VERY annoying solution and would cause me to leave your site immediately. How about this:
Code:
onunload="if (!window.a) alert('Goodbye!')"
and in <script> tags (After the body):
Code:
var onClickFunct=function() {a=1;};
for (var i = 0; i < document.links.length; i++)
 if (document.links[i].hostname == location.hostname)
  document.links[i].onclick=onClickFunct;


The above solution should work in all browsers. However, if the user presses back or forward, he'll get an annoying &quot;Goodbye!&quot; alert.

I don't suggest having an alert on your page... if the user intends to go away, the user will do so on his own accord.
Code:
- UNIMENT
 
While I agree that the goodbye popup should be avoided (and I find those annoying myself), in my experience if the domain name is checked immediately as the page loads, before anything is written to the popup page, and then closes if the viewer is still on the site, it's only a slight flash and click sound on slower connections (less than 28.8), and less on faster ones. The popup window never opens to even be visible. The other page is still loading and the items on that cover any possible actions/distractions from the opening and closing popup.
 
I'm on a 300 MHz, and having all the processor taken up for 3 seconds while a popup opens only to be closed again is an extreme annoyance.
Code:
- UNIMENT
 
Interesting. On an upgraded 90Mhz (Evergreen chip, to somewhere around 360Mhz), both IE 5.01 and Netscape 4.7 show no more than the window flashing on before closing, and the page behind loading normally. I don't use that technique to annoy people, but hadn't experimented with it before today.
 
Hello,

Thanks for your answers. They convinced me to give up with this goodbye popup.

And sorry for the other post I made in another thread, trying to explain my question...

Bye.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top