0
我無法獲取當前的內容頁面html。當我嘗試從xul元素的腳本訪問。不是當前打開的網址。如何從XUL獲取內容頁面?
我用這個代碼:
alert(document.getElementById("html"));
它會提醒空值,文檔返回XUL對象,而不是HTML對象。 我想解析當前的內容頁面,但我不知道該怎麼做。
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
alert(mainWindow.getBrowser().selectedBrowser.contentWindow.location.href);
alert(mainWindow.getBrowser().selectedBrowser.contentWindow.document);
當我使用此代碼,沒有警報顯示。