在页面显示之前加载Javascript警报 [英] Javascript alert loads before page displays

查看:88
本文介绍了在页面显示之前加载Javascript警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的手机上,在safari中如果我进入我的默认页面,该页面的正文onload事件中包含 alert(Hello),则会使用我的默认页面在后台完全可见。如果我然后转到另一个网站(例如bbc.co.uk),然后在地址栏中输入我的默认网页的网址,则该警报将显示BBC背景中的内容,就像在页面前加载警报一样已加载。



一旦整个页面可见,我如何才显示消息。我读过 window.onload 等到所有内容在触发警报之前加载完毕,但我必须出错,因为行为不会改变。我也试过:

$ $ $ $ $ $ $ $ $(document).ready(function(){
window.onload = alert ('Test');
});

 < meta http-equiv =Pragmacontent =no-cache/> 

如果它与缓存有关,但我认为这不是问题。任何想法?



谢谢

解决方案

  alert('Test'); 
});


On my mobile, in safari If I go to my default page that has alert("Hello") on the body onload event, the alert displays with my default page fully visible in the background. If I then go to another site for example bbc.co.uk and then type in my the web address for my default page in the address bar, the alert shows with the BBC content in the background, its like the alert loads before the page has loaded.

How do I only show the message once the whole page is visible. I've read that window.onload waits until everything is loaded before it triggers the alert but I must be getting something wrong because the behaviour doesn't change. I've also tried:

$(document).ready(function () {
    window.onload= alert('Test');
});

and

<meta http-equiv="Pragma" content="no-cache"/>

in case it has something to do with cache but I don't think this is the issue. Any ideas ?

Thanks

解决方案

$(window).load(function() {
      alert('Test');
});

这篇关于在页面显示之前加载Javascript警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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