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

后端 未结 5 1914
别跟我提以往
别跟我提以往 2021-02-12 03:53

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

5条回答
  •  不思量自难忘°
    2021-02-12 04:05

    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();
    

提交回复
热议问题