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!

navagation warning

Status
Not open for further replies.

aarrgghh

Technical User
Sep 5, 2002
60
US
Hey all,

Does anyone know of a way to warn a user to log out before navagating away from a web site? I need this warning to pop up under two circumstances. One when the user goes to a new domain, and if the user closes the browser window. Is this possible?

Thanks in advance
 
I would think that the onunload() event handler would allow you to pop-up an alert box.

There's always a better way...
 
in IE only, you can use the onbeforeunload event handler.

onunload won't work because it fires after the page is unloaded/closed - you cannot prevent the unload.



=========================================================
while (!succeed) try();
-jeff
 
A frabjous cheater method is to always have a warning window placed under your current working window. If the user exits the page In Accordance With Prophecy, the under-window is closed first, then the outer window. If they are so misguided as to bail out before you want them to, then upon dismissing the top window, they see the warning.

Furthermore, if you keep in that warning window a series of invisible controls dictating the current state of the app, one of the buttons "Bring it all back -- I'm misguided to want to leave now!" will completely restore their previous state. Voila!

That, at least, is how I would do it.

The trouble with popping up windows using the onunload event is that most browsers are well-behaved and won't do that kinda' junk upon exiting. Exiting is supposed to kill all child procs as well as the current one and a sudden pop-up window is quite definitely a child proc. IE is sloppy, however, and urges its children to strike out on their own, regardless of their broken home. Exploiting this allows unscrupulous marketers to populate your screen with all sorts of pop-up windows if you're running IE.

So, a possible solution for you, plus an explanation of one of the trickier bits.

Cheers,


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
>> frabjous

Ed, what is that? Can’t even find it anywhere…


-pete
I just can't seem to get back my IntelliSense
 
what is [frabjous]? Can’t even find it anywhere...

Now I know you don't use google. [lol]

"Frabjous" is a sort of synonym for especially good/joyful, as used in the Lewis Carroll poem "Jabberwocky", an example of which may be found at

When I discover or think up a particularly clever thing (whether fiendish or benign), I am often reminded that nonsense often sounds like nonsense only until it has been revealed otherwise. [smile]

Cheers,


[monkey] Edward [monkey]

"Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!" -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top