<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS效果-浏览器标题栏闪烁</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
// 使用message对象封装消息
var message = {
time: 1,
defaultTitle: document.title,
timer: null,
// 显示新消息提示
show: function () {
message.time++;
document.title = message.time % 2 == 0 ? "【新消息】" : "【 】";
document.title += message.defaultTitle;
if (!message.timer) {
message.timer = setInterval("message.show()", 600);
}
},
// 取消新消息提示
clear: function () {
clearInterval(message.timer);
document.title = message.defaultTitle;
}
};
message.show();
// 页面加载时绑定点击事件,单击取消闪烁提示
function bind() {
document.onclick = function () {
message.clear();
};
}
</script>
</head>
<body onload="bind();">
点击页面取消消息闪烁提示
</body>
</html>
原文地址:http://z2009zxiaolong.iteye.com/blog/1671413