• Javascript:新消息闪烁标题提示代码分享 (转)


    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="a01.aspx.cs" Inherits="a01" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>yyyyyy</title>
        <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
        <script type="text/javascript">
            var timerArr;
        
            ; (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 [timer, _title];
                        },

                        /**
                        * @param timerArr[0], timer标记
                        * @param timerArr[1], 初始的title文本内容
                        */
                        clear: function (timerArr) { //去除闪烁提示,恢复初始title文本
                            if (timerArr) {
                                clearInterval(timerArr[0]);
                                document.title = timerArr[1];
                            };
                        }
                    }
                });
            })(jQuery);

    //        jQuery(function ($) {
    //            timerArr = $.blinkTitle.show();

    //            setTimeout(function () {  //此处是过一定时间后自动消失
    //                $.blinkTitle.clear(timerArr);
    //            }, 10000);

    //            //若人为操作应该消失,只需如此调用: $.blinkTitle.clear(timerArr);
    //        });
           
        </script>
        <script type="text/javascript" >
            function Start() {


                //
            
                timerArr = $.blinkTitle.show();
                //
            }
            function End() {


                //
             
                $.blinkTitle.clear(timerArr);
                //
            }

        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
        </div>
        </form>
        <p>
            <input id="Button1" type="button" value="开始提示" onclick="Start();" />
            <input id="Button2" type="button" value="关闭提示" onclick="End();" />
        </p>
    </body>
    </html>

    download    demo

  • 相关阅读:
    关于INTEL FPGA设计工具DSP Builder
    关于FPGA电源精度要求
    基于INTEL FPGA硬浮点DSP实现卷积运算
    Redis 笔记(四)—— SET 常用命令
    Redis 笔记(三)—— LIST 常用命令
    Redis 笔记(二)—— STRING 常用命令
    Redis 练习(二)
    Redis 练习(一)
    Redis 笔记(一)——数据类型简介
    Java 中为什么不能创建泛型数组?
  • 原文地址:https://www.cnblogs.com/zhwl/p/2199287.html
Copyright © 2020-2023  润新知