title: On page reload, "window.print()" does not load the print dialog in Google Chrome 77.0.3865.120. This happens when an IFRAME is used with a PDF as SRC
body: <h1>Problem Description</h1>
  
  <p>With JavaScript, you can programmatically trigger the print dialog, by using <code>window.print()</code>. However, as soon as an <code>iframe</code> is loaded into the page with a <strong>PDF</strong> as the <code>src</code> and you refresh the page, the print dialog will no longer be shown when clicking on the button that should execute the <code>window.print()</code> function.</p>
  
  <p>The issue does not happen in MS Edge, neither in Firefox... Only the latest version of <strong>Google Chrome (77.0.3865.120)</strong> seems to be affected. Is this a Chrome bug?</p>
  
  <h1>Steps to reproduce the bug</h1>
  
  <ol>
  <li>Drop the below code in an html file and put it on a webserver (e.g. WampServer)</li>
  <li>Navigate in Chrome to index.html</li>
  <li>Click [Open print dialog]          ==> Ok</li>
  <li>Click [Create iframe]              ==> Ok</li>
  <li>Refresh index.html</li>
  <li>Click [Open print dialog]          ==> Not ok! Will not open the print dialog</li>
  <li>Only solution is closing the current Chrome Tab and reopening index.html</li>
  </ol>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta charset="utf-8"&gt;
          &lt;title&gt;Test Chrome bug with window.print()&lt;/title&gt;
          &lt;script&gt;
              function createMyIframe() {
  
                  // Create new element    
                  var myIframe = document.createElement('iframe');
  
                  // Add src attribute
                  myIframe.src = 'https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf';
  
                  // Suggestion of Amy does not solve the issue:
                  // Adding a **sandbox** attribute with a space-separated list of pre-defined values that will REMOVE the particular restrictions.
                  // Source: https://www.w3schools.com/tags/att_iframe_sandbox.asp
                  // Adding the following line is no solution. The iframe that is used in this example, will simply no longer open. Both the &lt;head&gt; and &lt;body&gt; tags of the iframe will be empty.
                  // myIframe.sandbox = 'allow-forms allow-modals allow-orientation-lock allow-pointer-lock allow-popups allow-popups-to-escape-sandbox   allow-presentation allow-same-origin allow-scripts allow-top-navigation allow-top-navigation-by-user-activation';
  
                  // Add the iframe to the page
                  document.body.appendChild(myIframe);
              }
          &lt;/script&gt;
      &lt;/head&gt;
  
      &lt;body&gt;
          &lt;h1&gt;Chrome version 77.0.3865.120 (Official build) (64-bits)&lt;/h1&gt;
          &lt;h2&gt;Bug with JavaScript "window.print()"&lt;/h2&gt;
  
          &lt;hr&gt;
  
          &lt;button onclick="window.print();"&gt;Open print dialog&lt;/button&gt;
          &lt;button onclick="createMyIframe()"&gt;Create Iframe&lt;/button&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <h1>Conclusion</h1>
  
  <p>The <code>window.print()</code> dialog becomes useless, as soon as you have an <code>iframe</code> on your page with a PDF as the <code>src</code> attribute.</p>