1. 程式人生 > >當用戶切換了窗口後改變title,感覺挺有趣的,收藏了

當用戶切換了窗口後改變title,感覺挺有趣的,收藏了

col set clear pos class post listener 感覺 settime

(function() {
    var OriginTitile = document.title, titleTime;
    document.addEventListener(‘visibilitychange‘, function() {
        if (document.hidden) {
            document.title = ‘切換瀏覽器窗口‘;
            clearTimeout(titleTime);
        } else {
            document.title = ‘切回來‘;
            titleTime 
= setTimeout(function() { document.title = OriginTitile; },2000); } }); })();

當用戶切換了窗口後改變title,感覺挺有趣的,收藏了