Javascript events

Discussion in 'JavaScript' started by dougyitbos, Dec 22, 2008.

  1. #1
    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
     
    dougyitbos, Dec 22, 2008 IP
  2. phper

    phper Active Member

    Messages:
    247
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    60
    #2
    Try onunload()
     
    phper, Dec 22, 2008 IP
  3. budster

    budster Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    budster, Dec 23, 2008 IP