jQuery:如何在选项卡/窗口获得焦点时告诉我 [英] jQuery: How can I tell when a tab/window gains focus

查看:65
本文介绍了jQuery:如何在选项卡/窗口获得焦点时告诉我的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次用户点击标签页时,是否有可以注册该标记的事件,这意味着它们位于我页面的标签页上,单击另一个标签页,然后返回到我的标签页。

Is there an event that I can register for that fires each time the user clicks on a tab, meaning that they were on my page's tab, clicked on another tab, then came back to my tab.

编辑:
按标签,我的意思是浏览器标签,而不是jQueryUI标签。

By tabs, I mean browser tabs, not jQueryUI tabs.

推荐答案

Matijis在评论中提供了这个答案,但我想接受它,所以这里作为答案。

Matijis provided this answer in a comment, but I wanted to accept it so here it is as an answer.

$(window).on('focus', function() { // your code });

这篇关于jQuery:如何在选项卡/窗口获得焦点时告诉我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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