[英]What tool can I use to find out what JavaScript events are being called when leaving a web page?
I have a set of pages that have tons of JavaScript on it: Table sorting, AJAX calls, autocomplete, dynamically hiding and displaying areas of the page, etc... The problem that I am seeing is when the data on said page gets large a delay (browser freezes) is noticed when leaving the page. 我有一组包含大量JavaScript的页面:表排序,AJAX调用,自动完成,动态隐藏和显示页面区域等……我所看到的问题是当所述页面上的数据变大时离开页面时出现延迟(浏览器冻结)。 This delay happens when the user clicks away, closes the browser, or executes a form submit.
当用户单击离开,关闭浏览器或执行表单提交时,就会发生这种延迟。 I want to see if the problem is caused by JavaScript.
我想看看问题是否由JavaScript引起。 What tool could I use to find out?
我可以使用什么工具来查找? Firebug doesn't seem to work in this scenario.
Firebug在这种情况下似乎不起作用。
The only place unload is mentioned in the codebase is in jquery.js and ui.tabs.js (jquery ui) 代码库中提到的唯一卸载地方是在jquery.js和ui.tabs.js(jquery ui)中
Are there any onunload event handlers attached (to body, window, form etc.)? 是否有任何onunload事件处理程序(附加到主体,窗口,窗体等)? If so, it would be a good starting point to investigate.
如果是这样,这将是一个很好的起点。
[Edit]: Apparently jQuery runs a loop unbinding all the events attached to every element. [编辑]:显然,jQuery运行一个循环,解除绑定到每个元素的所有事件的绑定。 This is to prevent memory leaks in IE (created due to event handler closures referencing the element they are listening to).
这是为了防止IE中的内存泄漏(由于事件处理程序关闭引用了它们正在侦听的元素而创建)。 This could create a delay if your DOM is very complex.
如果您的DOM非常复杂,则可能会造成延迟。
Can you try commenting this portion out in jQuery code and see if that is causing the problem? 您可以尝试在jQuery代码中将此部分注释掉,看看是否引起问题吗?
[Edit 2]: The window unload seems to have been improved in newer versions of jQuery (1.3+). [编辑2]:较新版本的jQuery(1.3+)中的窗口卸载似乎已得到改善。 What version are you using?
您使用什么版本?
内联代码查找器是一个firefox插件(实际上,它实际上是一个firebug插件),可以直观地向您显示在何处以及何时调用它们所附加的事件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.