title: Apply css styles to popup window using Javascript
body: <p>I have a jsp with multiple div's. I am getting the whole div data using <code>innerHTML</code> and displaying it to popup window. By using this I'm unable to get all the css styles. </p>
  
  <p>Here is the function:</p>
  
  <pre><code>function popupWin(cs) {
    var divText1 = document.getElementById("divId").innerHTML;
    var divText2 = document.getElementById("divId"+cs).innerHTML;
    var divText3 = document.getElementById("divId"+cs+"abc").innerHTML;
    var myWindow = window.open('',"mywindow","status=no,menubar=no,resizable=yes,toolbar=no,scrollbars=yes,addressbar=no,height=600,width=800");
    var doc = myWindow.document;
    doc.open();
    doc.write('&lt;link href="styles/shared/common.css" rel="stylesheet" type="text/css" /&gt;');
    doc.write('&lt;link href="styles/parent/common.css" rel="stylesheet" type="text/css" media="all" /&gt;');
    doc.write('&lt;link href="styles/parent/print.css" rel="stylesheet" type="text/css" media="print" /&gt;');
    doc.write('&lt;link rel="stylesheet" type="text/css" href="styles/admintool.css" /&gt;');
    doc.write(divText1);
    doc.write(divText2);
    doc.write(divText3);
    doc.close();
  }
  </code></pre>
  
  <p>By using this function only some styles are working.</p>