我想在特定时间后加载另一个 HTML 页面
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15719729/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 07:01:22 来源:igfitidea点击:
I want to load another HTML page after a specific amount of time
提问by ash9209
I have one html page "form1.html" which has an animated image. I want to load another page "form2.html" after 5 seconds. How do I do this?
我有一个带有动画图像的 html 页面“form1.html”。我想在 5 秒后加载另一个页面“form2.html”。我该怎么做呢?
采纳答案by Walialu
<script>setTimeout(function(){window.location.href='form2.html'},5000);</script>
And for home page add only '/'
而对于主页只添加'/'
<script>setTimeout(function(){window.location.href="/"},3000);</script>
回答by Majid Fouladpour
<meta http-equiv="refresh" content="5;URL='form2.html'">
回答by mehdi
use this JavaScript code:
使用此 JavaScript 代码:
<script>
setTimeout(function(){
window.location.href = 'form2.html';
}, 5000);
</script>
回答by Fleming Slone
Use Javascript's setTimeout:
使用 Javascript 的 setTimeout:
<body onload="setTimeout(function(){window.location = 'form2.html';}, 5000)">