退出函数on body onLoad [英] Quit function on body onLoad

查看:73
本文介绍了退出函数on body onLoad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个脚本,将用户重定向到第二面,当主页需要长时间加载。

I need a script thats redirects the user to a second side, when the mainpage need to long to load.

我这样做:

 <script type='text/javascript'>   
    $(document).ready(function() {
    setTimeout("location.replace('contact.html')",10000);
    });
</script>

为了sametime一个预加载器打开一个获取隐藏on body onload,当发生我需要杀死functon above?

To sametime a preloader opens an get hided on on body onload, when that happens i need to kill the functon above?

任何人都有想法?

推荐答案

var redirect = setTimeout(function(){
                  window.location = 'somewhere'
               }, 10000)

$(document).ready(function() { // or $(window).load(function() {
    clearTimeout(redirect);
});

这篇关于退出函数on body onLoad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆