简体   繁体   English

在离开网页时,我可以使用什么工具找出正在调用的JavaScript事件?

[英]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.

相关问题 如果 JavaScript 很少发生,我可以使用什么工具找出网页挂起的原因? - What tools I can use to find out what JavaScript hangs the web-page if it occurs rarely? 如何找出使用JavaScript的网站中正在调用的函数 - How to find out what functions are being called in a site that uses javascript 如何找出页面上正在使用的 javascript 对象? (挖掘 webpack 捆绑包) - how can I find out what javascript objects are in use on a page? (digging through a webpack bundle) 如何找出对象的onclick事件调用的javascript函数? - How do I find out what javascript function is being called by an object's onclick event? 我可以在单页面应用程序中使用浏览器Navigation Timing API进行Ajax事件吗?如果没有,什么是好工具? - Can I use the browser Navigation Timing API for Ajax events in single page apps? If not, what's a good tool? 逆向工程代码制作网页插件时,如何找到某个元素接收到事件时调用的函数? - When reverse engineering code to make a web page plugin, how can I find what function is called when a certain element receives an event? 如何找出HTML元素附加的事件? - How can I find out what events are attached to HTML elements? 如何找出从Javascript中的某个文件中正在调用什么函数 - How to find out what function is being called from a certain file in Javascript 单击页面上的某物时,如何发现调用了什么JavaScript函数? - How can I discover what JavaScript function is called when clicking on something on a page? 如何确定在javascript中调用的事件 - How to figure out what event is being called in javascript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM