# 网页标题/标签 闪烁
# 效果:
# 实现代码
let beforeTitle = document.title; // 原标签
let count = 0; // 切换title
function blinkNewMsg(val) {
document.title =
count % 2 == 0 ? `【 】${beforeTitle}` : `【${val}】${beforeTitle}`;
count++;
}
setInterval(() => {
blinkNewMsg('新消息');
}, 1000);
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10