1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

JavaScript: how to know if current window is active

Discussion in 'JavaScript and AJAX' started by hq9000, Jan 27, 2008.

  1. hq9000

    hq9000 New Member

    Joined:
    Jan 27, 2008
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello colleagues,

    I've got a question that might be silly, but anyway. How can i track the status of the window my JS script runs on? I mean how to know if this window is active or not.

    I've tried to tie handlers to 'onfocus' and 'onblur' events of the <BODY>, but the behaviour is rather strange - 'onblur' handler is NOT invoked when I switch between windows using ALT+TAB keys, even more - in IE when i switch to this window - both onfocus and onblue methos are instantly invoked.

    I guess that this approach is more suitable for handling user actions when filling a form or somethinh like it, and that there should be something much more tailored for tracking windows' status. Hope you can help me out to find it )))

    A lot of thanks in advance!
     
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,646
    Likes Received:
    86
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    try the onblur & onfocus on the window object not on body tag.
     

Share This Page