我有两个html页面:
在此我想首先加载 flash.html 页面5秒,然后自动 main.html 必须加载如何执行此操作?
我尝试了setTimeout(function(){ SplashBeGone(); }, 5000);
但我没有得到答案,任何人都可以帮助我吗?
答案 0 :(得分:1)
答案 1 :(得分:1)
SplashBeGone()
中的内容是什么?
我认为你会做类似的事情;
setTimeout( function(){window.location.href = "main.html"},5000);
答案 2 :(得分:1)
将其放在flash.html
区域的<head>
<meta http-equiv="refresh" content="5;URL='main.html '">
答案 3 :(得分:0)
你可以这样使用
<script language="javascript" type="text/javascript" src="js/jquery-1.9.0.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
setInterval(function() { //even setTimeout can be used
window.location.replace("main.html"); // redirect to main.html after 5 seconds
}, 5000);
});
</script>
答案 4 :(得分:0)
在 flash.html
的头部添加元刷新<head>
<meta http-equiv="refresh" content="5;URL='main.html'">
...
</head>
它比使用javascript更好。
答案 5 :(得分:0)
最好的方法是不使用Javascript
或jQuery
。您只需使用HTML Meta
代码。
<meta http-equiv="refresh" content="5;url=main.html" />
或完整网址
<meta http-equiv="refresh" content="5;url=http://www.example.com/main.html" />
您可以在此处详细了解如何使用元刷新:http://en.m.wikipedia.org/wiki/Meta_refresh
它适用于所有browsers
甚至mobile browsers
没有javascript
答案 6 :(得分:0)
只需使用此功能
即可
window.onload = function()
{
setInterval(function() {
window.location.replace("main.html");}, 5000);
}