dsp_099
dsp_099

Reputation: 6121

Is there a way to monitor javascript functions running on a page?

Is there a way to see which functions are being executed on a page?

If I load an external script on a page, is it possible to change what a function does on the fly or prevent it from running?

Upvotes: 3

Views: 1326

Answers (3)

Oriol
Oriol

Reputation: 288050

HTML5 introduces onbeforescriptexecute event, which you can use to detect new scripts on the fly, and block them if you want.

For example:

window.addEventListener('beforescriptexecute', function(e) {
    // e.target.src is the URL of the external loaded script
    // e.target.innerHTML is the content of the inline loaded script
    if (e.target.src === urlToBlock)
        e.preventDefault(); // Block script
}, true);

Upvotes: 4

Trey
Trey

Reputation: 394

https://developer.chrome.com/devtools/docs/javascript-debugging Here's a good place to start.

Upvotes: 0

Dusan
Dusan

Reputation: 276

Use Firebug for Firefox or Chrome Developer Tools. You can set the breakpoints and debug your code very well.

Upvotes: 0

Related Questions