Since you're parsing it as XML, you should let the parser know that your elements are HTML. This is done by specifying an appropriate (XHTML) namespace.

Also if you go that route, you ought to be calling adoptNode before appending the parsed tree to the tab's document, see http://www.w3.org/DOM/faq.html#ownerdoc

And, not selectedTab, but gBrowser.contentDocument.

If you wish to print HTML code, it probably would make more sense to use document.open / document.write

Nickolay


Eric H. Jung wrote:
OK, so I have this to create a new, empty tab and then insert content:

var wm = Components
  .classes["@mozilla.org/appshell/window-mediator;1"]
  .getService(Components.interfaces.nsIWindowMediator);

var win = wm.getMostRecentWindow("navigator:browser");
win.gBrowser.selectedTab = win.gBrowser.addTab("about:blank");
var content = "<html><body><p>hello, wurld</p></body></html>";
var dom = new DOMParser().parseFromString(content, "text/xml"); win.gBrowser.selectedTab.appendChild(dom.documentElement);

The string-to-DOM code works fine, but nothing appears in the new tab
after executing the appendChild() call. Should I call this on some
child or parent of win.gBrowser.selectedTab?

Thank you again,
Eric Jung


_______________________________________________
Project_owners mailing list
[email protected]
http://mozdev.org/mailman/listinfo/project_owners

Reply via email to