簡體   English   中英

當用戶轉到其他選項卡或最小化瀏覽器時,如何更改和閃爍瀏覽器的標題?

[英]How to change and blink the title of the browser when the user goes to other tab or minimizes the browser?

我想知道如何更改瀏覽器的標題,並在用戶打開另一個選項卡或只是最小化瀏覽器時將其設置為閃爍的文本。

對於閃爍標題:

var title = document.title;
var intv = window.setInterval(function () {
    document.title = document.title === '' ? title : '';
}, 500);

// call this to stop the blinking
function stopBlink() {
    window.clearInterval(intv);
    document.title = title;
}

至於在Tab切換或最小化上執行它, 可能window.onblur上運行代碼可以工作,但我猜它不能完成。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM