Reputation: 20837
I've got a page with a simple "print" image/link that executes a simple javascript onclick
handler. I'm finding that Chrome will complain about the page with a "Page Unresponsive" warning when I take too long to inspect the print dialog. I do not see this behavior in other browsers.
The HTML looks like this:
<a onclick="if(window.print) window.print(); return false;">
<img src="print-button.png" alt="[Print]" />
</a>
There are no other active scripts on the page, so I'm guessing that this onclick
handler is the problem. My guess is that Chrome does something like this behind the scenes:
onclick
handler existsonclick
handleronclick
handler calls window.print()
(which blocks, waiting for user input)I would consider this a bug in Chrome, if true, since the window.print
call shouldn't be "timed". That is, it's a blocking user-interactive action and the user is allowed to take as much time as they need.
I've tried cheating by doing this:
<a onclick="if(window.print) setTimeout(function() { window.print(); }, 0); return false;">
<img src="print-button.png" alt="[Print]" />
</a>
... but it does not change anything -- Chrome still complains about the long-running script.
Am I using the wrong technique to trigger the print dialog? Or is this a bug in Chrome?
I am running v72.0.3626.119 on 64-bit Mac and I cannot reproduce this while I have a client running the same version in 64-bit Windows and she is reporting this issue.
Upvotes: 5
Views: 647
Reputation: 800
This appears to be a known bug in Chrome since Feb 27 2018 / Chrome 64
There is a fix slated for Chrome 73
https://bugs.chromium.org/p/chromium/issues/detail?id=816869
Upvotes: 2