利用js实现网页标题title动态改变

技术
0

非常有趣的呦
复制下面代码到对应文件即可

<script type="text/javascript">
/*  动态网页标题*/
var OriginTitile = document.title,
titleTime;
document.addEventListener("visibilitychange",
function() {
    if (document.hidden) {
        $('[rel="shortcut icon"]').attr("href", "https://q1.qlogo.cn/g?b=qq&nk=805980740&s=100");
        document.title = "你别走吖 Σ(っ °Д °;)っ";
        clearTimeout(titleTime)
    } else {
        $('[rel="shortcut icon"]').attr("href", "https://q1.qlogo.cn/g?b=qq&nk=805980740&s=100");
        document.title = "你可算回来了 (。•ˇ‸ˇ•。)" + OriginTitile;
        titleTime = setTimeout(function() {
            document.title = OriginTitile
        },
        2000)
    }
});
</script>
最后更新 2022-08-26
评论 ( 0 )
OωO
隐私评论