1

I know about the debugger keyword: it works as a breakpoint if the developer tools are already open.

But is there a way to programmatically instruct the web browser to open the developer tools? I've cruised through the MDN docs but haven't found anything.

The use case would be that I need to debug a part of a web that gets opened in a new tab. I can't open it in the same tab and by the time I hit F12 I've already missed the code I'm trying to debug.

starball
  • 20,030
  • 7
  • 43
  • 238
perepm
  • 940
  • 9
  • 22
  • 2
    You can start most browsers with command line arguments or configure to automatically open dev tools on all new tabs. Does this help: [Automatically open Chrome developer tools when new tab/new window is opened](https://stackoverflow.com/questions/12212504/automatically-open-chrome-developer-tools-when-new-tab-new-window-is-opened#38366206)? – jabaa Jun 01 '22 at 11:26
  • Add `alert()` just before the code u need to debug. This will stop JS execution and provides you with ample of time to press F12 and open dev tools. –  May 03 '23 at 04:26

0 Answers0