[英]Open the Firefox browser console programatically from within an extension using JavaScript?
I have tried attaching toJavaScriptConsole()
to a button but this is not working (undefined reference error) 我尝试将
toJavaScriptConsole()
附加到按钮,但这不起作用(未定义参考错误)
How can I program an XUL button to open the firefox browser console so we can see logs from the extension? 如何设置XUL按钮以打开firefox浏览器控制台,以便我们可以查看扩展中的日志?
The following snippet will work. 以下代码段将起作用。
if(HUDService.getBrowserConsole()) // is it already open?
HUDService.getBrowserConsole().chromeWindow.focus();
else
HUDService.toggleBrowserConsole();
If you are in a scope where HUDService is not available then to get access to it do the following: 如果您在HUDService不可用的范围内,则要访问它,请执行以下操作:
var devtools = Components.utils.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
var HUDService = devtools.require("devtools/webconsole/hudservice");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.