js实现网页标题动态效果
将代码复制到head处即可
<script type="text/javascript">
/* 动态网页标题*/
var OriginTitile = document.title,
titleTime;
document.addEventListener("visibilitychange",
function() {
if (document.hidden) {
$('[rel="shortcut icon"]').attr("href", "https:/yejiuqiu.cn/favicon.ico");
document.title = "你别走吖 Σ(っ °Д °;)っ";
clearTimeout(titleTime)
} else {
$('[rel="shortcut icon"]').attr("href", "https://yejiuqiu.cn/favicon.ico");
document.title = "你可算回来了 (。•ˇ‸ˇ•。)" + OriginTitile;
titleTime = setTimeout(function() {
document.title = OriginTitile
},
2000)
}
});
</script>