我想做类似开心网001那样的效果,有好友消息,标题栏闪动。
    前台代码:
            <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">   
            <ContentTemplate>   
                       <asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick">
                </asp:Timer>  
            </ContentTemplate>     
        </asp:UpdatePanel>       后台代码:
        protected void Timer1_Tick(object sender, EventArgs e)
        {
            if (j % 3 == 0)
            {
                this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
                this.UpdatePanel1.Update();
            }
            j++;        }JS代码如下:
         <script type="text/javascript">
        var g_blinkswitch = 0;
        var g_blinktitle = document.title;
        function blinkNewMsg()
        {
        document.title = g_blinkswitch % 2==0 ? "【   】 - " + g_blinktitle : "【新消息】 - " + g_blinktitle;
        g_blinkswitch++;
        }
        function blink()
        {
        setInterval(blinkNewMsg, 1000);
        }
        </script> 求助各位高手......
代码很简单,每30秒闪动10秒,10秒timer一下

解决方案 »

  1.   

    <script language="JavaScript">
    var step=0;  //计数器变量,初始值为0
    function flash_title(){
      step++;  //变量递增
      if (step==3) {step=1};  //两种变化,所以大于3时回到1
      if (step==1) {document.title='\(^o^)/~开心网'};  //标题一
      if (step==2) {document.title='◎开心网'};  //标题二
      setTimeout("flash_title()",1000);  //每一秒钟变换一次
    }
    flash_title();  //调用函数自身
    </script>
    设置一个开关,或在<body>里用onLoad装载函数,样式为:onLoad="flash_title()"。
      

  2.   

    <body> <script type="text/javascript"> 
     var step = 0; 
     var st = null; 
     function flash_title() { 
     if (step == 5) { step = 0 } 
     if (step == 0) { document.title = '☆☆☆☆★☆☆☆☆' } 
     if (step == 1) { document.title = '☆☆☆★☆★☆☆☆' }
     if (step == 2) { document.title = '☆☆★☆☆☆★☆☆' }
     if (step == 3) { document.title = '☆★☆☆☆☆☆★☆' }
     if (step == 4) { document.title = '★☆☆☆☆☆☆☆★' }
     step++
     st = setTimeout("flash_title()", 30);
     }
     window.onfocus = function() {
     if (st != null)
     clearTimeout(st);
     }
     window.onblur = function() {
     flash_title();
     }
                 </script>
    </body>
    </html>    
                
               
      

  3.   

    zengzhan谢谢了。不过不是我本意,是因为我没有说清楚       我的最初是想让timer控件定时检测数据库,如果数据库有未读消息,那么标题栏闪动。。
            protected void Timer1_Tick(object sender, EventArgs e)
            {
                DataSet ds = B_Showmessage.getAllUnReadMsg();
                if (ds != null && ds.rows.count >0)
                {
                    this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
                    this.UpdatePanel1.Update();
                }
            } 
    如果不把Timer放入updatepanel中,页面就会刷新,闪动我是希望无刷新得让标题栏闪动
      

  4.   

    问题解决:
       把this.ClientScript.RegisterStartupScript(typeof(string), "js", "blink();", true);
      换成:
          ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.UpdatePanel1.GetType(), "msg", "blink();", true);   谢谢各位了