Chrome 可以在 Chrome 打开新标签页时自动打开其 Javascript 调试器吗?

Can Chrome open its Javascript debugger automatically when Chrome opens a new tab?

本文关键字:Chrome Javascript 调试器 标签 新标签      更新时间:2023-09-26

或者Chrome可以在打开源代码中包含"debugger"关键字的页面时自动打开调试器吗?

以前有一个命令行标志 - always-enable-devtools,看起来不再有。但是,您可以使用一个漂亮的技巧,尽管如果您不在OSX上,则必须摆弄一下才能重现我正在做的事情。

我做了两个shell脚本,'developer-chrome'和'debugger-chrome'。

developer-chrome 是我想要始终观察的实例,调试器-chrome 只会坐在我的第二个显示器中,这样我就可以看到控制台消息并在需要时戳 developer-chrome。

显影剂-铬

#!/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/
首先运行开发者镶边

,然后运行调试器镶边。Chrome 的两个实例都是自主的,因此您可以根据需要停止/重新启动它们。如果断开连接,则可能需要从调试器镶边手动重新连接到调试器。但。我不知道。

真的让我很恼火,因为没有办法让开发工具自动出现。再加上Chrome的"做了还是没有?"动态内容的缓存行为,几乎让我考虑了Firefox。

/当我在 Chrome(在 Mac 上)中使用以下debugger;它不会自动打开控制台,只有在开发人员工具都准备就绪时才运行。当做同样的事情并在 Firefox 中运行我的页面/脚本(安装了 Firebug)时,当点击 debugger; 语句时,JavaScript 控制台/调试器会打开。

只是我的经验..

是的。

谷歌浏览器可以打开debbuger,因为你使用标志debbuger。请参阅以下示例:

<script>
  (yourcode here)
  debugger;
  (next code to debug)
</script>

开发人员工具"源"面板将在该特定行中自动为您打开。

它也适用于Internet Explorer 11

在版本 43.x 上测试。