简体   繁体   English

jQuery:专注于窗口(谷歌浏览器?)

[英]jQuery: focus on window (Google Chrome?)

    var y = 0;
var focus = true;

$(window).bind('focus', function() {
    if(!focus) {        
        console.log("Hello");
        document.title = "title";
        focus = true;
    }
});

$(window).bind('blur', function() {
    if(focus) {
        document.title = "title (" + y + ")";
        focus = false;
        y++;
    }
});

Hey guys, 大家好,

the code above doesn't work as it was expected when changing tabs in Google Chrome, although it prints "Hello" in the console, it doesn't reset the title of the document to "title". 上面的代码无法按预期的效果在更改Google Chrome浏览器中的标签时起作用,尽管它在控制台中显示“ Hello”,但不会将文档标题重置为“ title”。 In Firefox and IE it works. 在Firefox和IE中可以使用。

Any help? 有什么帮助吗?

Thanks in advance. 提前致谢。

将变量的名称更改为focus以外的名称,因为它可能会引起冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM