Go4Expert

Go4Expert (http://www.go4expert.com/)
-   JavaScript and AJAX (http://www.go4expert.com/forums/javascript/)
-   -   JavaScript: how to know if current window is active (http://www.go4expert.com/forums/javascript-current-window-active-t8500/)

hq9000 28Jan2008 02:44

JavaScript: how to know if current window is active
 
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!

pradeep 28Jan2008 14:34

Re: JavaScript: how to know if current window is active
 
try the onblur & onfocus on the window object not on body tag.


All times are GMT +5.5. The time now is 20:00.