“停止运行该脚本”尝试导航到另一个页面时 IE7 和 IE8 中出现错误
我创建了一个使用 Openlayers 来显示地图的 Drupal 网站。在这些地图之一中,有一些“过滤器”,用户可以使用它们来动态更改地图中显示的数据。与国家相关的数据显示为国家上方的气泡。气泡是使用 Openlayers 的 API 绘制的。选择过滤器时,大量计算会在幕后进行。我使用 setTimeout 来避免长时间运行的循环。过滤器工作正常。但是,在单击多个过滤器后(例如,单击 12 个过滤器),如果用户尝试通过单击链接移动到另一个页面,则在 IE7 和 IE8 中会显示以下错误 -
“停止运行此脚本?
上的脚本此页面导致您的网络浏览器运行缓慢。 如果它继续运行,您的计算机可能会变得无响应。”
在单击链接之前,此错误不会在任何其他浏览器中显示,也不会在 IE7、8 中显示。任何这方面的指针都将受到高度赞赏。
更新 :问题出在 OpenLayers 的事件缓存中,OpenLayers 清除了窗口卸载事件中的事件缓存,并且在 IE7 和 IE8 中卡住了(到目前为止我不确定原因)。当用户单击另一个链接时,我已经能够通过在单击普通链接时调用 OpenLayers.Event.unloadCache() 来解决该问题。
I have created a Drupal website that uses Openlayers to display maps. In one of these maps there are some "Filters" which the user can use to dynamically change the data shown in the map. The data are related to countries are shown as bubbles over the countries. The bubbles are drawn using Openlayers' API. A good amount of calculations go behind the scene while filters are selected. I have used setTimeout to avoid long running loops. The filters work fine. However, after a number of filters are clicked (e.g. if 12 filters are clicked), if the user tries to move to another page by clicking a link, in IE7 and IE8 the following error shows -
"Stop running this script?
A script on this page is causing your web browser to run slowly.
If it continues to run, your computer might become unresponsive."
This error does not show in any other browser and does not show in IE7, 8 until a link is clicked. Any pointer in this regard will be highly appreciated.
UPDATE : The problem was in OpenLayers' event cache. OpenLayers's clears the event cache in the window unload event and this was getting stuck in IE7 and IE8 (I am not sure why). So far I have been able to solve the issue when user clicks another link, by calling OpenLayers.Event.unloadCache() on click of normal links.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
jQuery 的资源消耗可能非常大。下面链接的文章为您提供了 10 条好的建议,以帮助您更好地执行 jQuery 应用程序。对我来说最有用的(一个月前我也遇到过同样的问题)是将 $.each() 替换为传统的 for lops,并用 jquery 模板替换大量的 DOM 构造。还使用 ID 而不是类,并为选择器、选择器缓存等提供上下文。
该列表是根据我自己的建议中的“有用性”标准排序的。
10 种方法立即提高您的 jquery 性能
提高你的 jquery 25 个优秀技巧
来自 paul irish 的 10 个高级 jquery 性能调优技巧
8 个 jquery 性能技巧
jQuery can be very resource expensive. The articles linked bellow gives you 10 good advices to perform better your jQuery applications. The most useful for me (I had the same problem a month ago) was to replace $.each() with traditional for lops and to replace extensive DOM construction with jquery templates. Also the use of ID instead of classes and to give a context for the selectors, selector caching, and so on.
This list is ordered using my own criteria of "usefulness" in the advices.
10 ways to instantly increase your jquery performance
improve your jquery 25 excellent tips
10 advanced jquery performance tuning tips from paul irish
8 jquery performance tips
您需要优化您的客户端脚本。请参阅此处的答案。
You need to optimize your client script. Please refer to answers here.