Javascript print blocked by chrome

11,329

Solution 1

It appears to be a design decision rather than a bug. Getting around it will probably be pretty hard.

Solution 2

Sounds like a deliberate choice on Chrome's part that you probably won't be able to get around. As an alternative, you could prepare all of your jobs at once and separate them with a page break:

<div style="page-break-after:always"></div>

Solution 3

I have found the following to be a work-around to enable JavaScript printing from Chrome:

<a href="#" onclick="window.print(); return false;">Click me to Print</a>

It seems that adding the "return false" bit to the onclick handler makes Chrome happy.

I think that without it, Chrome attempts to follow the link somewhere / reload the page. This results in a print dialog showing nothing to print.

Solution 4

Good! Bug fixed. The bug was fixed as part of v.23 if I'm not wrong.

So if the release cycle is every 6 weeks and Chrome 22 was released 25th of Sep, then by 6th of November (aprox.) the fix will be in the Chrome Stable version

Share:
11,329
Oppdal
Author by

Oppdal

Updated on June 14, 2022

Comments

  • Oppdal
    Oppdal about 2 years

    I'm trying to run a javascript window.print() from chrome. It prints the first time but then subsequent calls (within a minute of the first call) fail. The chrome log states "Ignoring too frequent calls to print()."

         window.print();
     setInterval(function() {
         window.print();
     }, 5000);
    

    Can't find a way around this issue. Any ideas?

    Thanks in advance

  • Oppdal
    Oppdal over 13 years
    Thanks, I've since added a browser-check to see if agent's chrome, a counter & a timer. If they click the button > once within a minute I've got a subtle message that appears to ask them to Ctrl+P / menu print if nothing happens.
  • corbacho
    corbacho over 11 years
    I'm not going to down-vote. But the question is about "multiple and frequent calls to window.print", not about how to enable printing. The 'return false' didn't work to prevent this behavior (Chrome v.22)