hudeyong926 发表于 2013-1-23 02:39:14

利用jquery制作闪动标题

jquery获取head的title
$(document).ready(function(){alert($("title").html());$(document).title='dd';});jQuery(function($) {setInterval(function(){$.get("Untitled-2.html", function(data){if(data == 1){//有新消息var timerArr = $.blinkTitle.show();setInterval(function() {      //此处是过一定时间后自动消失$.blinkTitle.clear(timerArr);}, 4000)}else{$.blinkTitle.clear(timerArr);}});},4000);//若认为操作消失,只需如此调用:    $.blinkTitle.clear(timerArr);}); 送达方式发
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>新消息闪烁提示Demo</title></head> <body><p style="text-align:center;">请看网页标题处效果!    <br/>隔10秒后提示消失    </p><script type="text/javascript" src="../js/jquery-1.4.2.min.js"></script>    <script type="text/javascript">;(function($) {$.extend({/** * 调用方法: var timerArr = $.blinkTitle.show(); *$.blinkTitle.clear(timerArr); */blinkTitle : {show : function() {//有新消息时在title处闪烁提示var step=0, _title = document.title;var timer = setInterval(function() {step++;if (step==3) {step=1};if (step==1) {document.title='【   】'+_title};if (step==2) {document.title='【新消息】'+_title};}, 500);return ;},/** * @param timerArr, timer标记 * @param timerArr, 初始的title文本内容 */clear : function(timerArr) {//去除闪烁提示,恢复初始title文本if(timerArr) {clearInterval(timerArr);document.title = timerArr;};}}});})(jQuery);jQuery(function($) {var timerArr = $.blinkTitle.show();setTimeout(function() {//此处是过一定时间后自动消失$.blinkTitle.clear(timerArr);}, 10000);//若认为操作消失,只需如此调用:$.blinkTitle.clear(timerArr);});</script></body></html>
页: [1]
查看完整版本: 利用jquery制作闪动标题