js实现离开网页切换其他标签后随机改变页面的标题title
<script>document.addEventListener('visibilitychange', function () {
var a = Math.random() + "" //产生一个随机数
var rand1 = a.charAt(5) //的到这个数的第五个字符(实际还是从0~9的数字)
quotes = new Array //创建消息数组
quotes[1] = '也不再逛逛?' //这里分配十句随机出现的文本
quotes[2] = '这么着急就走啦?'
quotes[3] = '确定离开永生的网站?'
quotes[4] = '欢迎下次再来😘'
quotes[5] = '不要走😒'
quotes[6] = '别后悠悠君莫问,无限事,不言中'
quotes[7] = '从别后,忆相逢'
quotes[8] = '别时,我们没有流连的泪眼,相对,无语'
quotes[9] = '浮云一别后,流水十年间'
quotes[0] = '来也匆匆,去也匆匆😮'
var quote = quotes[rand1] //由随机数选择一句话
if (document.visibilityState == 'hidden') {
normal_title = document.title;
document.title = quote;
} else document.title = normal_title;
});
</script>
本文作者: 永生
本文链接: https://yys.zone/detail/?id=237
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!
评论列表 (0 条评论)