0

我的问题是,使用 mozrepl 创建并进入新窗口后,我无法提升到浏览器窗口上下文,怎么办?

ubugnu@spin-foam:~$ telnet localhost 4242 | tee -a .repl_log
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Welcome to MozRepl.

 - If you get stuck at the "...>" prompt, enter a semicolon (;) at the beginning of the line to force evaluation.
 - If you get errors after every character you type, see http://github.com/bard/mozrepl/wikis/troubleshooting (short version: stop using Microsoft telnet, use netcat or putty instead)

Current working context: chrome://browser/content/browser.xul
Current input mode: syntax

repl> repl.print(document.getElementById('toolbar-menubar'))
[object XULElement]
repl> win = open()
[object Window] - {window: {...}, document: {...}, external: {...}, getInterface: function() {...}, console: {...}, sidebar: {...}, performance: {...}, ...}
repl> repl.enter(win)
[object Window] - {window: {...}, document: {...}, InstallTrigger: {...}, external: {...}, webkitNotifications: {...}, getInterface: function() {...}, console: {...}, ...}
repl> repl.print(document.getElementById('toolbar-menubar'))

repl> repl.print("how to ascend to the browser window context?")
how to ascend to the browser window context?
repl> ?
4

1 回答 1

1

我对mozrepl 一点也不熟悉。但是从我在您的代码中看到的内容来看,也许您可​​以尝试win.opener访问您所在的当前窗口的打开器。例如:

repl.enter(win.opener);

或者,如果您可以访问组件(Cc、Ci、Cu),您可以尝试访问类型为“navigator:browser”的最新窗口:

var window=Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator).getMostRecentWindow("navigator:browser");
于 2013-05-19T22:04:58.707 回答