0

How can i detect if a browser tab is focused. I check this Detect If Browser Tab Has Focus

but it's only for IE. what for Google chrome and Firefox. Is there a generic solution for this.

Community
  • 1
  • 1
Abdul
  • 1,934
  • 7
  • 29
  • 59
  • http://stackoverflow.com/questions/1060008/is-there-a-way-to-detect-if-a-browser-window-is-not-currently-active – codemax Oct 28 '15 at 10:19

1 Answers1

0
document.addEventListener('visibilitychange', function(){
   document.title = document.hidden; // change tab text for demo
})

use this for Google chrome and Firefox.

Saurav Wahid
  • 371
  • 2
  • 8