Chrome 中的异步警报
当我们公司的地图网站加载时,应该会发生两件事:
- 出现一个包含免责声明的对话框
- 我们的地图 (GeoMoose) 加载
在 Firefox 和 IE 中,我可以在后台加载地图,同时显示免责声明setTimeout 异步调用alert()函数。在 Chrome 中,会显示对话框,但不会加载地图。在加载我们相当大的地图时,这会花费 0.5 -1.5 秒的宝贵加载时间。有没有更好的方法来异步显示可在 chrome 中使用的alert()消息?
这是相关代码:
<script type="text/javascript">
function alertUser(){
setTimeout(function() {alert("here is our disclaimer");},1);
}
</script>
<body onload="main(); alertUser(); ">
When our company's mapping website loads two things are supposed to happen:
- A dialogue box containing a disclaimer comes up
- Our map (GeoMoose) loads
In Firefox and IE, I am able to have the map load in the background while the disclaimer is displayed by using setTimeout to asynchronously call the alert() function. In chrome, the dialogue box displays and the map does not load. This costs .5 -1.5 seconds of precious load time while loading our rather large map. Is there a better way to asynchronously display an alert() message that will work in chrome?
Here is the pertinent code:
<script type="text/javascript">
function alertUser(){
setTimeout(function() {alert("here is our disclaimer");},1);
}
</script>
<body onload="main(); alertUser(); ">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
加载地图,并在加载所有内容后从回调运行
alert
。应该比较简单。请记住,您仍然会浪费用户使用您的地图可能花费的“宝贵”时间“0.5-1.5 秒”。您可能想在地图上方放置一个
,其中包含免责声明或类似内容。
Load the map and when everything is loaded run
alert
from a callback. Should be relatively simple.Keep in mind, you'll still be wasting ".5-1.5 seconds" of "precious" time the user could be spending using your map. You might want to put a
<div>
above the map with the disclaimer in it or something like that.