Yes, window.onfocus
and window.onblur
should work for your scenario:
http://www.thefutureoftheweb.com/blog/detect-browser-window-focus
More Related Contents:
- Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?
- Where to place JavaScript in an HTML file?
- Long processing time likely due to getValue and cell inserts
- Are eval() and new Function() the same thing?
- Ternary operators in JavaScript without an “else”
- Optimum way to compare strings in JavaScript? [duplicate]
- Unobtrusive JavaScript: at the top or the bottom of the HTML code?
- post increment vs pre increment – Javascript Optimization
- Does use of anonymous functions affect performance?
- What is the difference between Unary Plus/Number(x) and parseFloat(x)?
- Combine and Minify Multiple CSS / JS Files
- Server polling with JavaScript
- How to wait for a WebSocket’s readyState to change
- Why most JavaScript native functions are slower than their naive implementations?
- Why is iterating through an array backwards faster than forwards
- Using setInterval() to do simplistic continuous polling
- Javascript Performance: While vs For Loops
- jQuery AJAX polling for JSON response, handling based on AJAX result or JSON content
- Does the tag position in HTML affects performance of the webpage?
- Is optimizing JavaScript for loops really necessary?
- ES6 Tail Recursion Optimisation Stack Overflow
- Optimize long lists of fixed string alternatives in regex
- HTML5 Canvas Performance and Optimization Tips, Tricks and Coding Best Practices [closed]
- Javascript (jQuery) performance measurement and best practices (not load time)
- Polling API every x seconds with react
- What are some good css and js minimizers for production code? [closed]
- requestAnimationFrame garbage collection
- What is this asm style “x | 0” some javascript programmers are now using?
- How to do this while loop
- How to access the first property of a Javascript object?