且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如果用户当前在页面上处于活动状态,我如何使用JavaScript / jQuery进行检测?

更新时间:2021-10-10 09:21:59

您可以观看鼠标移动,但这是关于你在没有收听点击事件的情况下仍然存在的用户的***信息。但javascript无法判断它是活动标签还是浏览器甚至是打开的。 (好吧,你可以得到浏览器的宽度和高度,并告诉你它是否被最小化)

You can watch mouse movement, but that's about the best you're going to get for indication of a user still being there without listening to the click event. But there is no way for javascript to tell if it is the active tab or if the browser is even open. (well, you could get the width and height of the browser and that'd tell you if it was minimized)