在页面显示之前加载Javascript警报

编程入门 行业动态 更新时间:2024-10-10 19:16:46
本文介绍了在页面显示之前加载Javascript警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

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

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

谢谢

解决方案

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警报

本文发布于:2023-11-27 21:45:30,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   加载   页面   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!