引用jquery库
然后javascript代码(从百度借鉴来的)
<script type="text/javascript">
var text = "---您有新的消息!"
var s = $("title").html();
function show() {
document.title =s + text;
setTimeout("h()", 500);
}
function h() {
document.title =s;
}
$(function () {
var text = $("title").html();
setInterval(show, 1000);
});
</script>
用$("title").html(s+text);会报错,查了一下,用document.title =s + text;代替(兼容问题没有测试)
用setInterval("show()",1000);也不行,用setInterval(show, 1000);代替.若用setInterval("show()",1000);需要这样
$(function(){
$.extend({
show:function(){
alert("function");
}
});
setInterval("show()",3000);
});
show方法可以用ajax定时查询数据库消息提醒.