【问题标题】:I want to load another HTML page after a specific amount of time [duplicate]我想在特定时间后加载另一个 HTML 页面 [重复]
【发布时间】:2013-03-21 03:03:46
【问题描述】:

我有一个带有动画图像的 html 页面“form1.html”。我想在 5 秒后加载另一个页面“form2.html”。我该怎么做?

【问题讨论】:

  • 为什么在问题标题不在 jQuery 主题范围内时将 jQuery 问题标记为重复?!
  • ^ 巧妙的方法让您的第三页问题看起来像已获得 8800 人赞成的答案。

标签: javascript html timer


【解决方案1】:
<script>
    setTimeout(function(){
        window.location.href = 'form2.html';
    }, 5000);
</script>

主页只添加'/'

<script>
    setTimeout(function(){
        window.location.href = '/';
    }, 5000);
</script>

【讨论】:

    【解决方案2】:

    使用这个 JavaScript 代码:

    <script>
        setTimeout(function(){
           window.location.href = 'form2.html';
        }, 5000);
    </script>
    

    【讨论】:

      【解决方案3】:
      <meta http-equiv="refresh" content="5;URL='form2.html'">
      

      【讨论】:

        【解决方案4】:

        使用 Javascript 的 setTimeout:

        <body onload="setTimeout(function(){window.location = 'form2.html';}, 5000)">
        

        【讨论】:

        • 请避免使用长的内联javascript
        猜你喜欢
        • 2017-06-08
        • 1970-01-01
        • 2017-05-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-02-26
        • 1970-01-01
        相关资源
        最近更新 更多