如何查看实时调用的所有 JavaScript 函数?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7049510/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to view all JavaScript functions called in real time?
提问by Tomasz Smykowski
I want to figure out how a website reloads it's content using AJAX. Therefore i would like to see what JS functions are called in real time because I can't figure out what function is responsible for reloading the page dynamically. How to see all executed functions JS in real time in FF, Chrome, Opera or IE?
我想弄清楚网站如何使用 AJAX 重新加载其内容。因此我想看看实时调用了哪些 JS 函数,因为我无法弄清楚哪个函数负责动态重新加载页面。如何在 FF、Chrome、Opera 或 IE 中实时查看所有已执行的函数 JS?
采纳答案by KooiInc
Maybe using the 'profile' button in the firebug console tab can give you an indication of the function(s) that are fired. Furthermore you can tell firebug's console to show xmlhttp requests (expand 'console' at the top of the firebug screen. After that, If an ajax request fires, it should be visible in the console. In the 'post' tab in such a request you may be able to infer the function triggering the request, looking at the parameters.
也许使用萤火虫控制台选项卡中的“配置文件”按钮可以为您提供被触发的功能的指示。此外,您可以告诉萤火虫的控制台显示 xmlhttp 请求(在萤火虫屏幕顶部展开“控制台”。之后,如果触发 ajax 请求,它应该在控制台中可见。在此类请求的“发布”选项卡中您可以通过查看参数推断出触发请求的函数。
回答by Matthew
I think what you want is a feature in Chrome:
我认为你想要的是 Chrome 中的一个功能:
find the element that is being reloaded and right click, choose inspect from context menu, then right click the html of the element (in the bottom firebugish pane), in the context menu there are options to:
找到正在重新加载的元素并右键单击,从上下文菜单中选择检查,然后右键单击元素的 html(在底部的 firebugish 窗格中),在上下文菜单中有以下选项:
- break on subtree modifications
- break on attributes modifications
- break on node removal
- 中断子树修改
- 中断属性修改
- 节点移除中断
in your case maybe set "break on subtree modifications" on the body tag would do it?
在您的情况下,可以在 body 标签上设置“中断子树修改”吗?
Article on awesome new dev features in chrome: http://www.elijahmanor.com/2011/08/7-chrome-tips-developers-designers-may.html
关于 chrome 中令人敬畏的新开发功能的文章:http: //www.elijahmanor.com/2011/08/7-chrome-tips-developers-designers-may.html
回答by yasar
Install firebug in FF. Visit this link: http://getfirebug.com/
在 FF 中安装萤火虫。访问此链接:http: //getfirebug.com/
回答by laurent
I would do a big search and replace on all the file using a regular expression that matches the function names (something like "function (.*)\((.*)\){
") and use that to insert a console.log(functionName)
at the beginning the function.
我将使用与函数名称匹配的正则表达式(如“ function (.*)\((.*)\){
”)进行大搜索并替换所有文件,并使用它console.log(functionName)
在函数的开头插入一个。
So you search for function (.*)\(.*\){
and replace it with function \1 (\2){ console.log("\1");
(Note: Regular expressions are most likely wrong as I didn't check them - you'll need some testing to get it right).
所以你搜索function (.*)\(.*\){
并替换它function \1 (\2){ console.log("\1");
(注意:正则表达式很可能是错误的,因为我没有检查它们 - 你需要一些测试才能正确)。
It seems a bit crazy but it should work. I've used that method to debug a Director Lingo project.
这似乎有点疯狂,但它应该可以工作。我已经使用这种方法来调试 Director Lingo 项目。
Obviously, make sure you backup the whole project before doing the replacement.
显然,请确保在进行替换之前备份整个项目。
回答by dam_dam
I often using Firefox add-on JavaScript Deobfuscator
我经常使用 Firefox 插件 JavaScript Deobfuscator
https://addons.mozilla.org/en-us/firefox/addon/javascript-deobfuscator/
https://addons.mozilla.org/en-us/firefox/addon/javascript-deobfuscator/
回答by colonize
Following on the answer given in case you have access to the source code. With this regular expression you can do a console.log of all function calls:
如果您可以访问源代码,请按照给出的答案进行操作。使用此正则表达式,您可以执行所有函数调用的 console.log:
search for:
搜索:
function (.*){
replace with:
用。。。来代替:
function { console.log\(("")\);