Reference 2007 - Debt Consolidation - Credit Card Consolidation - Indian television shows news - Wordpress Themes

PDA

View Full Version : Javascript events


dougyitbos
Dec 22nd 2008, 11:20 am
Hi folks...

I need to show a div when a visitor attempts to leave my page.

I've tried using "onMouseout" on a div.
I've also tried onbeforeunload, and onbeforeunload

These events are not behaving as I expected.
The div shows when a user leaves the page - but also when the page loads.
That's no good.

Also - in the case of "onMouseout" it fires when I try to take the mouse over to the scroll bar and scroll down. Also not good.

I Need something that only shows when the user is leaving - not arriving, or scrolling.

What event should I be using?

Keep in mind I don't want to STOP them... just show a div to warn them about leaving in a current state.

I want to avoid the window.open as showing a div isn't a "pop up" and thus not likely to be blocked.

Thanks!
Doug

phper
Dec 22nd 2008, 9:14 pm
Try onunload()

budster
Dec 23rd 2008, 7:11 am
Hi Doug.
You have limited options when it comes to a user leaving the page. A div has no properties that will stop the window/page from closing.
A onbeforeunload can show a dialog alert box, which is not a popup window either.
See: http://projectwownow.blogspot.com/2008/09/confirm-browser-window-close-with.html if this could be useful to you.
Hope it helps