jquery如何检查所选的浏览器选项卡/窗口是否在我们的页面上?

如何检查用户当前是否在我们的页面上有浏览器的选项卡/窗口

function userisonourpage() { //do something } 

当用户将标签/窗口切换到我们的页面时?

 function tabswitched() { //dom something here too } 

就像在许多地方你切换到页面和标题更改我知道标题可以改为: document.title但不知道如何实现这些function。

感谢:D

你可以这样做:

 $(document).ready(function(){ $([window, document]).focusin(function(){ //Your logic when the page gets active }).focusout(function(){ //Your logic when the page gets inactive }); }); 

希望这可以帮助。 干杯