由JavaScript检查浏览器标签? [英] Check browser tabs by JavaScript?

查看:124
本文介绍了由JavaScript检查浏览器标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以检查是否为JavaScript主页是活动的浏览器IE7中/ FF /歌剧标签?

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

检查其他选项卡不到哪里这个JS运行可能会带来安全隐患,虽然页面..

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.

推荐答案

您可以附加的onblur 的onfocus 事件到窗口;这可以告诉你,如果你有焦点。我测试了这一点,它的工作原理。您不能检查另一页,但你绝对可以检查你自己的。

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.

这篇关于由JavaScript检查浏览器标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆