How to ignore certain script files / lines when debugging?

前端 未结 6 1277
南方客
南方客 2020-12-31 11:56

I\'m trying to debug some JavaScript, I want to find out what code gets executed when I hover over a certain div element (I\'ve got no idea which bit of code, because there\

相关标签:
6条回答
  • 2020-12-31 12:31

    You might want to take a look at Paul Irish's Re-Introduction to the Chrome Developer Tools, in particular the Timeline section (starts around 15 minutes into the video.)

    You can start recording all javascript events - function executions (with source lines etc) and debug based on what events fired. There are other really handy debugging tools hiding in that google IO talk that can help you solve this problem as well.

    0 讨论(0)
  • 2020-12-31 12:32

    If you're pretty sure it's a jQuery event handler you can try to poke around with the jQuery events. This will overwrite all the click handlers (replace with the type you're interested in) and log out something before each event handler is called:

    var elem = document.body; // replace with your div
    // wrap all click events:
    $.each($._data(elem).events.click, function(i, v) { 
        var h = v.handler; 
        v.handler = function() {
          // or use 'alert' or something here if no Dev Tools
          console.log('calling event: '+ i);
          console.log('event handler src: '+ h.toString()); 
          h.apply(h, arguments); 
        };
    })
    

    Then try calling the event type directly through jQuery to rule out that type:

    $('#your_div').click()
    
    0 讨论(0)
  • 2020-12-31 12:34

    You can use JavaScript Deobfuscator extension in Firefox: https://addons.mozilla.org/addon/javascript-deobfuscator/. It uses the same debugging API as Firebug but presents the results differently.

    In the "Executed scripts" tab it will show you all code that is running. If some unrelated code is executing as well it is usually easy enough to skip. But you can also tweak the default filters to limit the amount of code being displayed.

    0 讨论(0)
  • 2020-12-31 12:42

    Looks like you're looking for Visual Event.

    0 讨论(0)
  • 2020-12-31 12:53

    In FireFox this feature is called "Black boxing" and will be available with FireFox 25. It let's do exactly what you where looking for.

    This feature was also introduced to Chrome (v30+) although it's tougher to find/configure. It's called "skip through sources with particular names" and Collin Miller did an excellent job in describing how to configure it.

    Normally I'm for putting answers and howtos here instead of links but it would just end in me copying Collin's post.

    0 讨论(0)
  • 2020-12-31 12:53

    If using are using IE 7.0 onwards, you should have developer toolbar from where you can debug. Just use breakpoint where you need, rest of the code will not stop. Alternatavely you can define other applications like Interdev/ Visual Studio.net for debugging purpose too.

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