1

I have a HTML page(firstpage.html), my requirement is on load of that HTML (firstpage.html) in browser it should automatically enable the debugger for the page. So is there any way so that i can enable debugger automatically by using some java script code on my html page?

Thank You. Regards, Preetish.

1 Answers1

0

Try this JavaScript:

document.addEventListener('DOMContentLoaded', function(){
    debugger;
});

That's vanilla for the famous jQuery $(document).ready(function(){...});—it executes the contained code upon completion of the DOM loading.

2540625
  • 11,022
  • 8
  • 52
  • 58
  • Unfortunately, `debugger;` does not seem to do anything if devtools is not already open. –  Jul 19 '14 at 08:29
  • True, of course. OP should have Chrome Dev Tools open before loading the page (or before reloading). – 2540625 Jul 19 '14 at 08:31
  • Sure, but the OP seems to want to have it opened automatically for him. –  Jul 19 '14 at 08:33
  • Ah. OP doesn't use the word "open", only "enable", but I wonder now… – 2540625 Jul 19 '14 at 08:34
  • See also https://code.google.com/p/chromium/issues/detail?id=112277. –  Jul 19 '14 at 08:36
  • Also http://stackoverflow.com/questions/16660325/open-safari-google-chrome-developer-tools-programmatically-from-javascript. –  Jul 19 '14 at 08:37
  • Yes, it would seem an odd request to give JS code the ability to open my Dev Tools (or to perform similar browser modifications). – 2540625 Jul 19 '14 at 08:40