简体   繁体   English

html脚本,如何在重定向到另一个网页之前设置时间间隔

[英]html script ,how to set time interval before redirecting to another webpage

i want to set pause 5 seconds to display a loading gif image before it direct to webpage btw im using iframe and direct it to parent window how can i set that? 我想设置暂停5秒以显示正在加载的gif图像,然后再使用iframe将其直接定向到网页并直接将其定向到父窗口,该如何设置呢? please be gentle guys im kinda newbie on scripts thanks :D 请在脚本上成为绅士,我是一个新手,谢谢:D

<html>
<script>
 window.parent.location = "https://www.google.com"
</script>

<center>
  <img src=progress_bar.gif>
</center>

 </html>

Please try this in you script area: 请在您的脚本区域尝试以下操作:

setTimeout(function(){
    window.parent.location = "https://www.google.com"
},5000);

Use setTimeout like below to achieve what you want to. 使用如下所示的setTimeout实现您想要的。

setTimeout(function(){
window.parent.location = "https://www.google.com"
},5000);

Use setTimeout : 使用setTimeout:

 setTimeout(function(){
    window.parent.location = "https://www.google.com";
 }, 5000);

Maybe a meta-refresh-tag is working for you? 也许元刷新标签对您有用吗?

<meta http-equiv="refresh" content="2;url=http://webdesign.about.com/">

The 2 means, that the site is redirected after 2 seconds. 2表示站点在2秒后被重定向。

Look at javascript setTimeout 看看javascript setTimeout

It will look like: setTimeout('window.parent.location = "https://www.google.com"', 5000); 它将类似于: setTimeout('window.parent.location = "https://www.google.com"', 5000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM