繁体   English   中英

使用JavaScript从扩展程序中以编程方式打开Firefox浏览器控制台?

[英]Open the Firefox browser console programatically from within an extension using JavaScript?

我尝试将toJavaScriptConsole()附加到按钮,但这不起作用(未定义参考错误)

如何设置XUL按钮以打开firefox浏览器控制台,以便我们可以查看扩展中的日志?

以下代码段将起作用。

if(HUDService.getBrowserConsole()) // is it already open?
  HUDService.getBrowserConsole().chromeWindow.focus();
else
  HUDService.toggleBrowserConsole();

如果您在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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM