使用JavaScript以编程方式打开Safari / Google Chrome开发者工具 [英] Open Safari / Google Chrome developer tools programmatically from JavaScript

查看:455
本文介绍了使用JavaScript以编程方式打开Safari / Google Chrome开发者工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法,通过连接到网页的脚本打开WebKit开发人员工具。我需要Google Chrome和Safari的解决方案,如果它尚未打开,它将打开developer-tools窗格,并且(希望如果能够弄清楚)如何在打开时切换到所述窗格的特定选项卡/部分。 / p>

(用例,如果有人感兴趣:如果已经存在,我想打开 console.log 输出窗口一个错误和一个开发人员正在查看页面;这个特定的页面将是一些JavaScript单元测试的输出。)






<我在这个问题上设置了一个奖励,因为它显然是一个以前没有回答过任何人的满意的答案,答案是多毛的。请不要回答它,除非您有真正的答案:1)在两个浏览器中都有效,2)不需要专用扩展API从一个静态的网页工作。



请参阅(相关,但特定于Chrome和扩展):可以以编程方式打开谷歌浏览器扩展程序中的开发工具吗?

解决方案

简单:不能



(不像任何网页),因此授予沙盒环境时,打开和控制非垃圾箱环境的权力是主要安全设计缺陷



我希望这能回答你的问题: - )


I'm looking for a way to open the WebKit "developer tools" from a script attached to a web-page. I need solutions for both Google Chrome and Safari, that will open the developer-tools pane if it's not already open, and (hopefully, if you can figure out how) also switch to a particular tab/section of said pane upon opening.

(Use-case, if anyone's interested: I want to open the console.log output-window if there's been an error and a developer is looking at the page; this particular page will be the output of some JavaScript unit-tests.)


I'm setting a bounty on this question because it's obviously one that hasn't been answered to anyone's satisfaction before, and the answer is a hairy one. Please don't answer it unless you have a real answer that both: 1) works in both browsers, and 2) doesn't require private extension APIs that won't work from a static web-page.

See (related, but specific to Chrome, and extensions): Can I programmatically open the devtools from a Google Chrome extension?

解决方案

Simply: You can't.

The Dev Tools are not sandboxed (unlike any web page), thus granting sandboxed environments the power to open and control an unsandboxed environment is a major security design flaw.

I hope this answers your question :-)

这篇关于使用JavaScript以编程方式打开Safari / Google Chrome开发者工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆