x 秒后更改 HTML 页
Change HTML page after x second
我使用 phonegap 开发了一个移动应用程序。
我有两个文件 html(splash.html,index.html)。
所以,我希望该应用程序以 splash.html 开头,并在 X 秒后将页面更改为 index.html。
如何使用 javascript 执行此操作?
与JavaScript:
setTimeout(function() {
window.location.href = 'index.html';
}, 2000);
没有JavaScript:
<head>
<!-- ... -->
<meta http-equiv="refresh" content="2; url=index.html">
</head>
您只能使用 HTML 重定向元标记执行此任务,如下所示:
<meta http-equiv="refresh" content="5; url=http://yoursite.com/">
我没有在您的网站绝对 URL 之后精确任何文件是因为加载了默认文件,并且 index.html
是默认文件。
试试这个:
function delay(){
setTimeout(function(){
window.location.href='index.html'
},5000);}
function delay(){
setTimeout(function(){
window.location.href='index.html'
},5000);}
我使用 phonegap 开发了一个移动应用程序。 我有两个文件 html(splash.html,index.html)。 所以,我希望该应用程序以 splash.html 开头,并在 X 秒后将页面更改为 index.html。
如何使用 javascript 执行此操作?
与JavaScript:
setTimeout(function() {
window.location.href = 'index.html';
}, 2000);
没有JavaScript:
<head>
<!-- ... -->
<meta http-equiv="refresh" content="2; url=index.html">
</head>
您只能使用 HTML 重定向元标记执行此任务,如下所示:
<meta http-equiv="refresh" content="5; url=http://yoursite.com/">
我没有在您的网站绝对 URL 之后精确任何文件是因为加载了默认文件,并且 index.html
是默认文件。
试试这个:
function delay(){
setTimeout(function(){
window.location.href='index.html'
},5000);}
function delay(){
setTimeout(function(){
window.location.href='index.html'
},5000);}