在標(biāo)題欄顯示新消息提示,很多公司項(xiàng)目中用到這個(gè)方法
更新時(shí)間:2011年11月04日 17:27:26 作者:
在標(biāo)題欄顯示新消息提示,很多公司項(xiàng)目中用到這個(gè)方法,需要的朋友可以參考下。
復(fù)制代碼 代碼如下:
<a href="#" onclick="clearNewMessageRemind();return false;">點(diǎn)擊取消閃爍提示</a>
<script type="text/javascript">
var newMessageRemind={
_step: 0,
_title: document.title,
_timer: null,
//顯示新消息提示
show:function(){
var temps = newMessageRemind._title.replace("【 】", "").replace("【新消息】", "");
newMessageRemind._timer = setTimeout(function() {
newMessageRemind.show();
//這里寫Cookie操作
newMessageRemind._step++;
if (newMessageRemind._step == 3) { newMessageRemind._step = 1 };
if (newMessageRemind._step == 1) { document.title = "【 】" + temps };
if (newMessageRemind._step == 2) { document.title = "【新消息】" + temps };
}, 800);
return [newMessageRemind._timer, newMessageRemind._title];
},
//取消新消息提示
clear: function(){
clearTimeout(newMessageRemind._timer );
document.title = newMessageRemind._title;
//這里寫Cookie操作
}
};
newMessageRemind.show();
function clearNewMessageRemind() {
newMessageRemind.clear();
}
</script>
相關(guān)文章
javascript實(shí)現(xiàn)日期三級聯(lián)動(dòng)下拉框選擇菜單
這篇文章主要介紹了javascript實(shí)現(xiàn)日期三級聯(lián)動(dòng)下拉框選擇菜單,實(shí)現(xiàn)JS年月日三級聯(lián)動(dòng)下拉框選擇功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04使用typescript類型來實(shí)現(xiàn)快排詳情
這篇文章主要介紹了使用typescript類型來實(shí)現(xiàn)快排詳情,文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下2022-08-08JS監(jiān)聽滾動(dòng)和id自動(dòng)定位滾動(dòng)
這篇文章主要為大家詳細(xì)介紹了JS監(jiān)聽滾動(dòng)和id自動(dòng)定位滾動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12BootStrap給table表格的每一行添加一個(gè)按鈕事件
這篇文章主要介紹了BootStrap給table表格的每一行添加一個(gè)按鈕事件的相關(guān)資料,需要的朋友可以參考下2017-09-09原生js實(shí)現(xiàn)的觀察者和訂閱者模式簡單示例
這篇文章主要介紹了原生js實(shí)現(xiàn)的觀察者和訂閱者模式,結(jié)合簡單實(shí)例形式分析了js觀察者和訂閱者模式的相關(guān)原理與實(shí)現(xiàn)技巧,需要的朋友可以參考下2020-04-04