![](/img/trans.png)
[英]How to redirect and render the url gotten from an API response object on the browser using express and axios
[英]Why can not the browser url be gotten from a dialog window (Firefox)?
Salvete! 我的一個js文件中有一個函數,可從主瀏覽器窗口獲取網址。 我的插件是一個工具欄。 從工具欄的javascript調用此函數可以正常工作。
但是,我還有另一個使用此函數的對話框窗口(通過xul)(通過窗口加載偵聽器調用),但是當調用它時,盡管函數確實觸發了,但它給了我: TypeError: window.content is null
。
function GetTheBrowserUrl(){
var browserwindow = window.top.getBrowser().selectedBrowser.contentWindow.location.href;
return browserwindow;
//return getBrowser().contentWindow.location.href;
}
那么如何從對話框窗口中使它起作用呢? 似乎從對話框窗口調用該函數需要以某種方式在瀏覽器窗口上獲取一個句柄。
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var window = wm.getMostRecentWindow("navigator:browser");
return window.gBrowser.contentWindow.location.href
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.