Reputation: 7938
Or can Chrome open debugger automatically when it opens a page which contains 'debugger' keyword in its source code?
Upvotes: 7
Views: 3995
Reputation: 517
Yes.
The Google Chrome can open the debbuger since you use the flag debbuger. See example below:
<script>
(yourcode here)
debugger;
(next code to debug)
</script>
The Sources panel of Developers Tools will automatically open for you in that specific line.
It also works for Internet Explorer 11.
Tested on version 43.x.
Upvotes: 0
Reputation: 28036
Previously there was a command line flag --always-enable-devtools, doesn't look like there is anymore. However, there's a nifty trick you can use although if you're not on OSX you'll have to fiddle around a bit to reproduce what I'm doing.
I made two shell scripts, 'developer-chrome' and 'debugger-chrome'.
developer-chrome is the instance I want to always be observing, debugger-chrome will just sit in my second monitor so I can see console messages and poke developer-chrome when I want.
#!/bin/bash
export PROFILE=$HOME/develop-chromium-profile
export DISK_CACHEDIR=/tmp/develop-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
--remote-debugging-port=4096 \
--user-data-dir=${PROFILE} \
--enable-experimental-webgl=yes \
--window-position=3000,400 \
--window-size=1200,1000 \
--no-pings \
--disk-cache-dir=${DISK_CACHEDIR} \
--disk-cache-size=${DISK_CACHESIZE} \
--media-cache-size=${MEDIA_CACHESIZE} \
--disable-geolocation \
--ash-immersive \
--disable-application-cache \
--pinned-tab-count=1 http://some_url_im_developing_on/
#!/bin/bash
export PROFILE=$HOME/debugger-chromium-profile
export DISK_CACHEDIR=/tmp/debugger-chromium-profile-cache
export DISK_CACHESIZE=0
export MEDIA_CACHESIZE=0
/Applications/Chromium.app/Contents/MacOS/Chromium \
--user-data-dir=${PROFILE} \
--enable-experimental-webgl=yes \
--window-position=2400,400 \
--window-size=1200,1000 \
--no-pings \
--disk-cache-dir=${DISK_CACHEDIR} \
--disk-cache-size=${DISK_CACHESIZE} \
--media-cache-size=${MEDIA_CACHESIZE} \
--disable-geolocation \
--ash-immersive \
--disable-application-cache \
--pinned-tab-count=1 http://localhost:4096/
Run developer-chrome first, then debugger-chrome. Both instances of chrome will be autonomous so you can stop/restart them if you wish. You may have to manually reattach to the debugger from the debugger-chrome if you get disconnected.. but. I dunno.
It really irks me that there's no way to get devtools to just come up automatically. That coupled with Chrome's 'did it or didn't it?' caching behavior with dynamic content has almost gotten me to consider Firefox.
Upvotes: 1
Reputation: 15291
/When I've used the following in Chrome (on a Mac) debugger;
it will not open the Console automatically and will only run if the Developer Tools are all ready active. When doing the same and running my page/script in Firefox (with Firebug installed) the JavaScript Console/Debugger is opened when the debugger;
statement is hit.
Just my experience..
Upvotes: 0