admin 管理员组文章数量: 1184232
I'm analyzing a site where the document.location.hash changes after some seconds since page loaded. It seems something asynchronous. Is possibile to debug who change the hash, via Chrome inspector?
By now I only add a "watch" but is hasn't breakpoint.
Thanks
I'm analyzing a site where the document.location.hash changes after some seconds since page loaded. It seems something asynchronous. Is possibile to debug who change the hash, via Chrome inspector?
By now I only add a "watch" but is hasn't breakpoint.
Thanks
Share Improve this question asked Feb 28, 2018 at 16:24 MerlinoxMerlinox 3773 silver badges9 bronze badges1 Answer
Reset to default 10You can enable an event listener breakpoint for "hashchange":
As of 2019 Q4, this functionality exists in the "Sources" tab, in a panel titled "Event Listener Breakpoints".
When code now makes a change to location.href Chrome would stop at a handler for this event:
You can now go to the cause using the "Call Stack" panel.
This only works when there's already an event handler for hashchange.
Assuming you don't have such an event handler in your code yet, create an event handler like this:
window.addEventListener("hashchange", function(e) {
debugger;
});
本文标签: javascriptChrome Debug who changes documentlocationhashStack Overflow
版权声明:本文标题:javascript - Chrome: Debug who changes document.location.hash - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.roclinux.cn/p/1744028613a2521085.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论