i cannot get current content page html. when i trying access from script in xul element. not current open url.
i use this code:
alert(document.getElementById("html"));
it will alert null value, document return XUL object, not Html object.
I want parsing current content page, but i dont know how to do it.
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);
when i use this code, no alert shown.
If you run this code from the
windowcontext, you can just remove the first part and have: