简体   繁体   中英

Force chrome to refresh a page while debugging with breakpoints

If I have a breakpoint in a loop or frequent interval I can't refresh chrome without forcing a reload with ctrl-r .

Hitting F5 /clicking the refresh button will do a normal refresh, loading just the modified content, unless the debugger has paused on a breakpoint in which case the debugger continues. Holding/spamming F5 just cycles through breakpoints and I can't refresh the page after spotting a bug and making code changes. I'd prefer not to do a full reload ( ctrl-r ) because I have images and other content that get cached and don't need to be re-downloaded.

One solution is to close the debugger, refresh and then open the debugger. However, the JS then gets a chance to run before the debugger is back up. I then have to refresh again so the JS runs from the beginning.

Has anyone found a workaround?

It could be just me, but I frequently want to make changes to my code and debug it at the same time.


  • Refresh: F5

  • No, actually refresh: 锤子 + F5 ?

What works for me is to CMD + R (I'm on OS X) then F8 .

It seems that reload is done only after you pass the current breakpoint.

Right click on refresh button. Then choose one of the reload options.

Have you tried running the following from the Console?

window.location.reload()

What would reload only the content of the page, and not web inspector.

A simple solution could be to use the "Deactivate breakpoints" button. This will let the flow happen without stopping.

Then you can use the F5 to just reload the changes.

UPDATE

Given you want to have breakpoints enabled as soon as you load the page, you can do following.

  1. Set a global flag = true in your page. Say, window.shouldbreak = true;
  2. Set up your breakpoints as "conditional breakpoints" as described here Chrome Dev Tools Debugging Javascript . Of course your condition will be if(window.shouldbreak === true) then break else proceed.
  3. Run your regular debugging flow.
  4. Once done. In console set window.shouldbreak = false; Now the debugger won't stop at any of the breakpoints for current session.
  5. On page reload with F5 , because the variable is set again in the page, you have your breakpoints working again

This is to echo @Munteanu Sergiu's answer. Here is a screenshot on OS/X.

在此输入图像描述

In Chrome, Debug Toolbar, go to settings icon at the bottom left corner (or on the toolbar header) and choose disable cache. then try reloading.

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