我有两个 html 页面:
- flash.html
- main.html
在这我想先加载flash.html页面 5 秒钟,然后自动加载main.html怎么做?
我试过 setTimeout(function(){ SplashBeGone(); }, 5000);
但我没有得到答案有人可以帮助我吗?
我有两个 html 页面:
在这我想先加载flash.html页面 5 秒钟,然后自动加载main.html怎么做?
我试过 setTimeout(function(){ SplashBeGone(); }, 5000);
但我没有得到答案有人可以帮助我吗?
您可以为此使用元刷新: http ://en.m.wikipedia.org/wiki/Meta_refresh
里面有什么SplashBeGone()
?
我会假设你会做类似的事情;
setTimeout( function(){window.location.href = "main.html"},5000);
把这个放在你flash.html
的<head>
区域
<meta http-equiv="refresh" content="5;URL='main.html '">
你可以用这种方式
<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>
只需简单地使用此功能
window.onload = function()
{
setInterval(function() {
window.location.replace("main.html");}, 5000);
}
在flash.html的头部添加元刷新
<head>
<meta http-equiv="refresh" content="5;URL='main.html'">
...
</head>
它比使用 javascript 要好得多。
最好的方法是没有Javascript
or 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