最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How do I pause everything running on a webpage? - Stack Overflow

programmeradmin0浏览0评论

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 badges
Add a ment  | 

5 Answers 5

Reset to default 3

Whenever you want to add breakpoint enter the following in debug console (F12 in Chrome):

debugger;

It works in most browsers.

  1. Open Developer Tools (Ctrl + Shift + I)
  2. Go to Console tab
  3. 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.

发布评论

评论列表(0)

  1. 暂无评论