Chrome javascript debugger breakpoints don't do anything?

前端 未结 21 997
时光说笑
时光说笑 2020-12-02 18:14

I can\'t seem to figure out the Chrome debugging tool.

I have chrome version 21.0.1180.60 m.

Steps I took:

  1. I pressed ctrl-shift-i to bring up t
相关标签:
21条回答
  • 2020-12-02 18:46

    make sure that you have opened javascript console(or sources) in your chrome window. otherwise it will never hit the breakpoint. you can open javascript console by option button in right upper corner-->tools-->javascript console.

    0 讨论(0)
  • 2020-12-02 18:47

    as I experienced with chrome we need to open browser console to make debugger run when loading page.

    put this somewhere in javascript file you want to run

    debugger
    

    open browser console and reload page.

    debugger will run like example image below

    0 讨论(0)
  • 2020-12-02 18:47

    I'm not sure how it worked, but hitting F1 for settings and at the bottom right, hitting "Restore defaults and reload" worked for me.

    0 讨论(0)
  • 2020-12-02 18:47

    Pretty late answer but none of the above helped my case and was something different

    while referring the javascript file type="text/javascript" was missing in the legacy application i was working

    <script  src="ab.js" ></script>
    

    below one worked and breakpoints were hitting as expected

     <script  src="ab.js" type="text/javascript"></script>
    
    0 讨论(0)
  • 2020-12-02 18:48

    Make sure the script with the "debugger;" statement in it is not blackboxed by Chrome. You can go to the Sources tab to check and turn off blackboxing if so.

    EDIT: Added screenshot.

    0 讨论(0)
  • 2020-12-02 18:48

    I encountered similar problems in both chrome and firefox though it may not be the solution for your issue. Am sharing here in the hopes it may help others. I have encountered this situation before in other unrelated projects but never understood why until it cropped up again today.

    Scenario:

    I have one page that uses two bootstrap modals that come from the same source and one set of javascript files (blueimp's awesome jquery fileupload).

    • BS Modal 1 is rendered on page load (via php) and is always present on the page. It is used for adding a new related record. (CakePHP....think SalesForcey type stuff)

    • BS Modal 2 is used for editing existing related records and it's html content is pulled in from an ajax call and appended to the DOM via jQuery.

    • Javascript supporting both modals included via standard html <script> tags.

    I noticed that breakpoints are only triggered on Modal 1. They do not work when the code is being executed on the dynamically added Modal 2, even though it is quite obvious that the code is indeed being evaluated and run. Alert boxes pop up, codey type things get executed and output follows the logic set forth in the code.

    I have not dived deeper to investigate further because I'm pressed for time, but wanted to put it out there and give back to the community.

    PS: I use SO all the time, but this is my first post, so go easy on me :-)

    0 讨论(0)
提交回复
热议问题