简体   繁体   中英

How to pause JavaScript after page done loading?

I am loading an HTML page in my browser from a web site. As far as I understand, the browser loads the page first, then starts executing the JavaScript code on it.

Question: How can I pause the JavaScript execution in Google Chrome as soon as the page is done loading, and then start it after, manually?

What I am trying to achieve is to load the page in a browser (any browser, but preferably Google Chrome), but edit the javascript code before it starts executing.

Well, in Google Chrome you can achieve this with the developer tools (and in most other popular browsers). Open them with F12 and set a breakpoint in your script under the "Sources" tab.

You can then edit and save (Ctrl-S) your script and press F8 to continue execution with the new code.

Check out Debugging Javascript in Chrome . You can set breakpoints at the beginning of any JS file and then continue from there.

Debugging with breakpoints

A breakpoint is an intentional stopping or pausing place in a script. Use breakpoints in DevTools to debug JavaScript code, DOM updates, and network calls.

Click the line gutter to set a breakpoint for that line of code. A blue tag will indicate if a breakpoint has been set

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM