简介:
为网站加上一个动态标题
离开网页标题就会变,回来后就会恢复正常
代码:
<script>
//动态标题
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
},
1000)
}
});
</script>
评论