Can I open a new window and populate it with a string variable?
HTML
Archer's answer is a good one, but you can do this in a one liner if you wish:
window.open("data:text/html;charset=utf-8,"+html, "", "_blank")
Opening XML?
window.open("data:text/xml;charset=utf-8,"+xml, "", "_blank")
With XML, make sure you string begins with <?xml version="1.0" encoding="UTF-8"?>
and has a root element. If it doesn't, you can easily add it:
window.open('data:text/xml;charset=utf-8,<?xml version="1.0" encoding="UTF-8"?><RootTag>'+xml+'</RootTag>', "", "_blank")
Archer's answer is the best way. But you need to close the document to run the scripts inside the "htmlString".
var wnd = window.open("about:blank", "");
wnd.document.write(htmlString);
wnd.document.close();
Yes it's possible...
var wnd = window.open("about:blank", "", "_blank");
wnd.document.write(html);
That should do the trick.