📜  javascript 使标题闪烁 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:17.705000             🧑  作者: Mango

代码示例1
var isOldTitle = true;
var oldTitle = "oldTitle";
var newTitle = "newTitle";
var interval = null;
function changeTitle() {
    document.title = isOldTitle ? oldTitle : newTitle;
    isOldTitle = !isOldTitle;
}
interval = setInterval(changeTitle, 700);

$(window).focus(function () {
    clearInterval(interval);
    $("title").text(oldTitle);
});