How to detect if the user switched to another window?

Discussion in 'JavaScript' started by Michau, Feb 5, 2006.

  1. #1
    I have some JavaScript code which works on image with client-side map and omMOuseOver and onMouseOut events. Basically, I have such code:

    <AREA ... onMouseOut="function1()" onMouseOver="function2()">
    <AREA ... onMouseOut="function1()" onMouseOver="function2()">

    When the user hovers over an area, some text is shown with DHTML. When he removes the mouse from the area, the text is hidden.

    Now the problem is, Internet Explorer apparently does not fire the onMouseOut event when user switches over to another window with Alt+Tab. The text is still displayed. So the effect is this: I hover the mouse over one area, and text for this area is displayed. Then I switch to another window with Alt+Tab, and move the mouse pointer. Then I switch back to IE, and it happens that the moue now hovers over another area, so its text is displayed, BUT THE PREVIOUS TEXT DID NOT DISAPPEAR.

    Firefox does not have this problem, so I guess it's IE related. Do you know a solution for this?
     
    Michau, Feb 5, 2006 IP
  2. arnek

    arnek Active Member

    Messages:
    134
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    53
    #2
    I would guess try doing something with onBlur() maybe on the window object ... thats just a guess.
     
    arnek, Feb 6, 2006 IP
  3. dataman

    dataman Peon

    Messages:
    94
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I would just create a element listener object and set my event handler to create the function based on the key press or mouse event. This way you support most all of the newer browsers without the need to do different things for each. If I saw you full code, I could show how to do it.

    da!
     
    dataman, Feb 6, 2006 IP