在特定时间后,我希望加载另一个HTML页面。

68

我有一个名为"form1.html"的html页面,其中包含一个动画图片。我希望在5秒后加载另一个页面"form2.html"。我该如何做到这一点?


为什么在问题标题与jQuery主题无关的情况下,将一个jQuery问题标记为重复?! - Mojtaba Rezaeian
请查看以下链接:https://dev59.com/_3RB5IYBdhLWcg3wz6Wd#25537534。 - Patrick W. McMahon
1
巧妙的方法是让你的第三页问题看起来像被接受的答案,它有8800个赞。 - coreyward
4个回答

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

对于主页只需添加'/'

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

20
<meta http-equiv="refresh" content="5;URL='form2.html'">

17

使用以下 JavaScript 代码:

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

1
使用JavaScript的setTimeout函数:
<body onload="setTimeout(function(){window.location = 'form2.html';}, 5000)">

1
请避免使用过长的行内 JavaScript。 - corn on the cob

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接