Check browser tabs by JavaScript?

你。 提交于 2019-12-06 09:17:54

问题


Can I check if host page for a JavaScript is active by the browser's tab in IE7/FF/Opera?

Checking other tabs than the page where this JS runs would probably be a security risk though..

My other option is a method I remember by prototype to check if the mouse cursor is active, but it's not that accurate.


回答1:


You can attach the onBlur and onFocus events to the window; that will tell you if you have focus or not. I have tested this and it works. You cannot check another page, but you can definitely check your own.



来源:https://stackoverflow.com/questions/512087/check-browser-tabs-by-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!