Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jan 2007
    Location
    Monterrey, Mexico
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question window.onblur -- how does this work?

    Hi all...
    I have a little problem.

    I want to be able to detect when the user moves away from the current active browser window.

    The reason i want to do this is because i have a dhtml menu which remains open no matter what.

    so this is what i want to do..


    Code:
    window.onblur=function(){ 
          menuBar.closeAllMenus(); 
    }

    but the code isnt executed when i move away from the window!
    can someone help me with this?

    i've also tried this:


    Code:
    window.onblur=function(){ 
          window.alert("AH!"); 
          closeMenus(); 
    } 
    
    function closeMenus(){ 
          window.alert("IN"); 
          menuBar.closeAllMenus(); 
    } 
    </script> 
    </HEAD> 
    
    <body topmargin="0" leftmargin="0" onblur="closeMenus()">
    and its not working

    I cant post the whole menu code because its VERY long, but i know the
    menuBar.closeAllMenus() instruction works.. i've tried it with

    Code:
    function closeMenus(){ 
          menuBar.closeAllMenus(); 
    } 
    setInterval(closeMenus,1000);

    and sure enough every second all the menus are closed.

    is there another way to know if the user is leaving the window?

    right now the page is divided into 2 frames, im working with the top frame where the menu is.

    does that affect the behaviour of window.onblur ?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Can you post a link to the page? Why not just do a setTimeout() onmouseout of each link?
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •