admin管理员组文章数量:1325332
I have a piece of JavaScript code running in browser and I want to pause it to see what values are in the console.
I have a lot of logs going on so I need to see whats logged at a certain point through running the script.
I am running chrome, is there a button or shortcut to do this ?
I have a piece of JavaScript code running in browser and I want to pause it to see what values are in the console.
I have a lot of logs going on so I need to see whats logged at a certain point through running the script.
I am running chrome, is there a button or shortcut to do this ?
Share Improve this question asked Aug 19, 2015 at 12:19 thatOneGuythatOneGuy 10.7k9 gold badges58 silver badges92 bronze badges5 Answers
Reset to default 3Whenever you want to add breakpoint enter the following in debug console (F12
in Chrome):
debugger;
It works in most browsers.
- Open Developer Tools (Ctrl + Shift + I)
- Go to
Console
tab - Paste this to the console:
setInterval(() => { debugger; }, 5000)
Now make the page to be on the state that you want (open drawers, open gallery menus, etc...) after 5 seconds (you can tweak this 5 seconds by changing 5000
to other numbers 5 * 1000 = 5000
) website will freeze.
Now do what you wanna do with the site!
This is what you are looking for.
https://developer.chrome./devtools/docs/javascript-debugging
You can pause scripts and hover your mouse over to see variable values at that point in the script. Enjoy.
You must to use developer tools. If you use the debugger you can put break points and pause in exceptions. You can view variable values, objects structure, and much more information.
Maybe this link is useful for you: https://developer.chrome./devtools/docs/javascript-debugging
Good luck
PD: Note that firefox's developer tools are better and more plete than chrome developer tools, but in essence are for the same purpose.
F12 brings the Developer Tools. There, go to Sources and pick your source script. You may either change some lines to include a debugging directive, namely
debugger
which will pause the processing and let you fiddle around.
There is also a possibility of signing a line where you want to pause, by simply clicking on the line's number in source view in the developer tools.
本文标签: javascriptHow do I pause everything running on a webpageStack Overflow
版权声明:本文标题:javascript - How do I pause everything running on a webpage? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742195852a2431064.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论