Search code examples
javascriptjqueryhtmldom

Can I open a new window and populate it with a string variable?


I am having a bit of a battle with something that seems simple. I have a [javascript] string that has DOM elements in it and would like to open a new window (window.open()?) and use the string the populate the new window. i.e. have the browser take the string and convert it into HTML on the fly. Is this possible?


Solution

  • Yes it's possible...

    var wnd = window.open("about:blank", "", "_blank");
    wnd.document.write(html);
    

    That should do the trick.