JS 根据浏览器标签页是否被选中改变标签页title

$(function(){
    var OriginTitile = document.title, titleTime;
    document.addEventListener('visibilitychange', function() {
        if (document.hidden) {
            document.title = 'Come back !';
            clearTimeout(titleTime);
        } else {
            document.title = 'Welcome to MyHome';
            titleTime = setTimeout(function() {
                document.title = OriginTitile;
            },3000);
        }
    });
})

 

posted @ 2019-02-15 17:12  格鲁特baby  阅读(143)  评论(0编辑  收藏  举报