JavaScript 倒计时 - 块文本框

JavaScript Countdown - Block Text Box

我的网站上有一个注销网页。我在我的网页上添加了一个 JavaScript 片段,这样 5 秒后,它就会重定向回我的主页。我还有一个从 5 倒数的文本框。

我想做的是在我的网页上保留文本框并保持倒计时,唯一的是我想让文本框不可编辑。尽管这真的没有任何作用,但它可能很烦人。

下面是我网页上的 JavaScript 脚本:

<script type="text/javascript">
//<![CDATA[
      var targetURL="http://www.ecer.ca/index.php"
      var countdownfrom=5


      var currentsecond=document.redirect.redirect2.value=countdownfrom+1
      function countredirect(){
      if (currentsecond!=1){
      currentsecond-=1
      document.redirect.redirect2.value=currentsecond
      }
      else{
      window.location=targetURL
      return
      }
      setTimeout("countredirect()",1000)
      }

      countredirect()
      //]]>
      </script>

我将该脚本连接到一个表单:

<form name="redirect">
      <center>
        <font face="arial" size="4"><strong>Please wait. You will
        be redirected in</strong></font>
          <font face="arial" size="4"><strong><input type="text"
          size="4" name="redirect2" /></strong></font>
        </form>

如有任何帮助,我们将不胜感激!谢谢!

将属性 disabled="disabled" 添加到 <input /> 元素。这将使输入不可编辑。

您的 HTML 应如下所示:

<form name="redirect">
    <center>
        <font face="arial" size="4">
            <strong>Please wait. You will be redirected in</strong>
        </font>
        <input type="text" size="4" name="redirect2" disabled="disabled"  />
    </center>
</form>