0

I need to load the div inside the pop up window.

Currently I am able to load the direct html content in it through document.write but how do I load a div(with a form in it) inside the pop window.

Here is the current code

function myFunction() {
            var myWindow = window.open("", "MsgWindow", "width=200, height=100");
            myWindow.document.write("<p>Need to load the .content div here</p>");
        }

Jquery/JavaScript anything would do.

Here is the working DEMO

  • None of [these](http://stackoverflow.com/search?q=[javascript]populate+pop-up+window)? – Teemu Sep 07 '15 at 07:46
  • 1
    replace `

    ` with `

    ` and you have a form. what is the problem ?
    – Hacketo Sep 07 '15 at 07:47
  • possible duplicate of [How to move an element in the DOM?](http://stackoverflow.com/questions/14088650/how-to-move-an-element-in-the-dom) – Hacketo Sep 07 '15 at 07:52

1 Answers1

0

This is the changes I made to your code:

function myFunction() {
    var myWindow = window.open("", "MsgWindow", "width=200, height=100");

    myWindow.document.write($(".content").html());
    myWindow.document.close();

}

Here is the JSFiddle demo

Ahs N
  • 8,233
  • 1
  • 28
  • 33