title: Unable to print iframe content from parent page in IE 11
body: <p>The below is the javascript code that had been working fine for me in IE 8 on Windows XP. </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function printFrame(frameId) {
         var iframe = $('#'+frameId)[0]; 
         iframe.contentWindow.focus(); 
         iframe.contentWindow.print(); 
      }
  &lt;/script
  </code></pre>
  
  <p>The above function is called then the "Print Frame" button is clicked in parent page.</p>
  
  <pre><code>&lt;iframe id="testFrame" src="" name="testFrame"&gt; &lt;/iframe&gt;
  
  &lt;input type="button" onclick="printFrame('testFrame')" value="Print Frame"/&gt;
  </code></pre>
  
  <p>Recently,  I upgraded my machine to Windows 7 and IE 8 to IE 11.</p>
  
  <p>Now this same function does not give the expected result of printing the iframe contents. 
  I tested this in chrome v34, firefox 30. This seems to work  in them except in IE 11.</p>
  
  <p>On researching, I found that when iframe src is dynamically set, iframe.contentWindow does not return the excepted iframe window object.</p>
  
  <p>I tried using window.print() inside the jsp in iframe. This seems to work if the src is not changed dynamically. But I need to change the contents of iframe to be dynamically set according to the selection in another drop down box in parent page. </p>
  
  <p>For example , check the below link in IE 11.</p>
  
  <pre><code>http://plungjan.name/SO/testprintiframe.html
  </code></pre>
  
  <p>The first time the link prints the contents on iframe. Then, click on the button. This results in the parent window being sent to printer instead of the iframe contents. </p>
  
  <p>Then I tried another method. 
  Wrote the below code in the iframe contents jsp and tried to access it from parent page. I was unable to access the method itself. 
  "script code in iframe jsp"</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function printFrame() {
         window.print();
      }
  &lt;/script
  </code></pre>
  
  <p>"script code in parent jsp"</p>
  
  <p>Try 1:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function printMyFrame(frameId) {
          var iframe = $('#'+frameId)[0]; 
          $(iframe).contents().printFrame();
      }
  &lt;/script
  </code></pre>
  
  <p>Try 2: </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function printMyFrame(frameId) {
         setTimeout(function() {
            window.frames[frameId].contentWindow.printFrame();
          }, 200);
       }
  &lt;/script&gt;
  </code></pre>
  
  <p>I searched and implemented almost all the methods found on google search to access the iframe window instead of the parent window. But have been unable to print the iframe contents using IE 11. </p>
  
  <p>Please guide me as to how to print the iframe contents in IE 11. </p>