2

This is the only thing I can think:

$(document).ready(function () {
  $([window, document]).focusin(function(){
    alert('hi');
  }).focusout(function(){
    alert('see you');
  });

But it doesn't work. It should show an alert when not viewing the page, and another one when viewing the page. Of course this is not my final application but it should work that way. Any suggestion?

jQuery is loaded, other actions inside $(document).ready() are working, no errors are shown...

Mohammad
  • 21,175
  • 15
  • 55
  • 84
Jonhas
  • 125
  • 1
  • 1
  • 9
  • Have you tried `focus` and `blur` instead? ...and you don't need to assign these in `$(document).ready()`. The `window` and `document` are immediately available. – the system Mar 05 '13 at 20:29
  • possible duplicate of [Is there a way to detect if a browser window is not currently active?](http://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active) – Kevin B Mar 05 '13 at 20:31
  • see here http://stackoverflow.com/questions/1760250/how-to-tell-if-browser-tab-is-active – PSR Mar 05 '13 at 20:31
  • I'm sorry, didn't find that question when I searched. Thank you! – Jonhas Mar 05 '13 at 20:39

0 Answers0