Chrome: window.print() print dialogue opens only after page reload (javascript) Chrome: window.print() print dialogue opens only after page reload (javascript) google-chrome google-chrome

Chrome: window.print() print dialogue opens only after page reload (javascript)


Wasiim is right, there is a Chrome bug where window.print() does not work when there is a <video> tag in the DOM. I solved it by calling this function:

function printPage() {    window.print();    //workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633    if (window.stop) {        location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear        window.stop(); //immediately stop reloading    }    return false;}


From my experience this is due to continued background traffic, e.g. ajax calls and the like that prevent Chrome from feeling the that page is loaded completely. The reload breaks all traffic and thus the print dialog pops up.This is a particular gotcha in Visual Studio 2013 where BrowserLink continually ticks away in the background. This can be tested by disabling BrowserLink via the setting below:

<configuration>    <appSettings>        <add key="vs:EnableBrowserLink" value="false"/>    </appSettings></configuration>


I have exactly same problem with Chrome. You need to manually reload page:

    <a href="javascript:window.print();window.location.reload()">Print</a>