简体   繁体   English

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

[英]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.

相关问题 使用javascript在firefox扩展程序中打开面板 - Open a panel in a firefox extension using javascript javascript打开firefox扩展名 - javascript to open a firefox extension 是否可以使用javascript以编程方式在Firefox文件打开对话框中设置“从:”字段 - Is it possible to programatically set the “from:” field in a Firefox file open dialog using javascript 使用JavaScript打开Mozilla Firefox浏览器 - Open Mozilla Firefox Browser using JavaScript Firefox扩展。 如何从控制台访问“浏览器”名称空间? - Firefox extension. How to access “browser” namespace from console? 在磁盘上的新浏览器选项卡中使用 javascript 以编程方式打开 html 文件 - Open an html file programatically using javascript in a new browser tab from disk 使用javascript在Chrome浏览器的新标签页中以编程方式打开URL - Programatically open the URL in new tab in chromium browser using javascript 尝试使用来自自定义Firefox扩展/附加组件的xpath和javascript来引用页面中的文本失败 - Failing at attempt to reference text within a page using xpath and javascript from a custom Firefox extension/add-on 从扩展程序的javascript获取firefox浏览器窗口句柄 - Get the firefox browser window handle from the extension's javascript 有没有办法触发使用php和javascript从Firefox浏览器打开IE窗口? - is there a way to trigger an IE window to open from firefox browser using php and javascript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM