首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >mozrepl:进入新打开的窗口时,转到浏览器窗口的上下文

mozrepl:进入新打开的窗口时,转到浏览器窗口的上下文
EN

Stack Overflow用户
提问于 2013-05-19 06:17:45
回答 1查看 637关注 0票数 0

我的问题是,在使用mozrepl创建并进入一个新窗口后,我无法跳转到浏览器窗口上下文,该如何做?

代码语言:javascript
复制
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> ?
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-20 06:04:59

我对mozrepl一点也不熟悉。但从我在您的代码中看到的情况来看,也许您可以尝试使用win.opener来访问当前窗口的打开程序。像这样:

代码语言:javascript
复制
repl.enter(win.opener);

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

代码语言:javascript
复制
var window=Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator).getMostRecentWindow("navigator:browser");
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16629520

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档