[英]What's the best way to figure out which javascript code that change specific html content in page
我在我的网页上有<p>
标签,我试图找出在此元素中添加文本的JavaScript函数,是否有任何特定的方法在chrome中添加此标记上的侦听器以找出在此标记上写入的脚本?
The most direct (low noise) way uses a sync pause that lets you poke around in the whole call stack: 最直接(低噪音)方式使用同步暂停,让您在整个调用堆栈中徘徊:
Once the element's "innerHTML" changes, the script execution will pauses and you can view the whole call stack in the "Sources" tab, including whatever function requested the DOM change. 一旦元素的“innerHTML”发生变化,脚本执行将暂停,您可以在“Sources”选项卡中查看整个调用堆栈,包括请求DOM更改的任何函数。
Certain DOM modifications like animation libraries can use a setTimeout
or callback that discards much of the call stack that lead up to the change, and in those cases, a Profile might be more interesting, since the animation function should stand out like a sore thumb in a "Heavy" view. 某些DOM修改(如动画库)可以使用
setTimeout
或回调来丢弃导致更改的大部分调用堆栈,在这种情况下,Profile可能会更有趣,因为动画功能应该像一个痛苦的拇指一样突出一个“沉重”的观点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.