javascript 浏览器提示有消息

给个小实例,注意在IE下的,没考虑兼容性,把以下代码拷贝到文本中,改成test.html就可以了

<a href="#" onclick="clearNewMessageRemind();return false;">Stop flash</a>
<script type="text/javascript">
var newMessageRemind={
_step: 0,
_title: document.title,
_timer: null,

show:function(){
var temps = newMessageRemind._title.replace("[ ]", "").replace("[New Message]", "");
newMessageRemind._timer = setTimeout(function() {
newMessageRemind.show();

newMessageRemind._step++;
if (newMessageRemind._step == 3) { newMessageRemind._step = 1 };
if (newMessageRemind._step == 1) { document.title = "[ ]" + temps };
if (newMessageRemind._step == 2) { document.title = "[New Message]" + temps };
}, 800);
return [newMessageRemind._timer, newMessageRemind._title];
},

clear: function(){
clearTimeout(newMessageRemind._timer );
document.title = newMessageRemind._title;

}
};
newMessageRemind.show();
function clearNewMessageRemind() {
newMessageRemind.clear();
}
</script> 



你可能感兴趣的:(JavaScript,timer,浏览器,function,IE,null)