一网页,功能是三秒后转入其他网页
我想加上个倒计时
准备用label
在源码里写
<script   type="text/javascript">
      function Refresh2()
      {
        document.getElementById("LabelSecond").setAttribute("Text","2秒");
      }
      function Refresh1()
      {
        document.getElementById("LabelSecond").setAttribute("Text","1秒");
      }
      window.setTimeout("Refresh2()",1000);
      window.setTimeout("Refresh1()",1000);
</script>非常笨的方法,但是还是没有作用想问:
1.javascript动态显示是不是必须要HTML的标准Label控件(我用的这个是.net的)
2.我要的这个功能该如何实现

解决方案 »

  1.   

    label 
    在发给客户端后就是
    span了,不再是 lable
    所以,代码如下:<script  type="text/javascript"> 
          function Refresh2() 
          { 
            document.getElementById("LabelSecond").innerHTML="2秒"; 
          } 
          function Refresh1() 
          { 
            document.getElementById("LabelSecond").innerHTML"1秒"; 
          } 
          window.setTimeout("Refresh2()",1000); 
          window.setTimeout("Refresh1()",1000); 
    </script> 
      

  2.   

    两个问题
    1.要HTML标准控件才有.innerHTML属性,我用的这个是.net component
    2.我用的visual studio在HTML的控件下找不到Label
      只有Input(Button) 之类的
      

  3.   

    Page.RegisterStartupScript("onload","script")
      

  4.   

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>无标题文档</title>
    <script  type="text/javascript"> 
         
      var iTime = 3; 
          function Refresh() 
          { 
                 iTime = iTime - 1;
          if(iTime == 0)
      {
          //执行跳转
      } 
      else
      {
                document.getElementById("LabelTime").innerHTML = iTime + "秒"; 
        
      }
          } 
           
      window.setInterval("Refresh()",1000);
      
    </script> 
    </head><body>
    <span id="LabelTime"></span>
    </body>
    </html>
      

  5.   

    string script = "<script  type=\"text/javascript\">function Refresh2(){document.getElementById(\"LabelSecond\").setAttribute(\"Text\",\"2秒\");}function Refresh1(){document.getElementById(\"LabelSecond\").setAttribute(\"Text\",\"1秒\");}window.setTimeout(\"Refresh2()\",1000); window.setTimeout(\"Refresh1()\",1000);</script>"
    Page.RegisterStartupScript("onload",script)