簡體   English   中英

mozrepl:在新打開的窗口中輸入時轉到瀏覽器窗口的上下文

[英]mozrepl: go to the context of the browser window when entering in a new opened window

我的問題是,使用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> ?

我一點都不熟悉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");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM