Are there any way to stop the running of a Javascript web application when the focus is on other window?
For example, If I have AJAX executions in a application web, It’d very efficient stop the running in that situation.
Are there any way to stop the running of a Javascript web application when
Share
Problem with the page visibility api is, that it’s not cross browser compatible. No Safari, no IE<10.
https://developer.mozilla.org/en-US/docs/DOM/Using_the_Page_Visibility_API
You could try to use the windows focus and blur events. (jQuery Example)
It’s not that fancy as the page visibility api, because it only tells you, whether the tab is focused or not, but it might be enough to achieve, what you’re trying to do.