Javascript - print pdf to iframe with Firefox workaround

I am using this bit of javascript to print a PDF that is displayed in an iframe.

function printPage()
{
  var div = document.getElementById("printerDiv");
  div.innerHTML = '<iframe src="/cgi-bin/pr.pl?tx.pdf"   onload="this.contentWindow.focus();this.contentWindow.print();"></iframe>';
}

      

Works fine in Chrome, but in Firefox I am getting the following error due to a Firefox bug that has been around for over a year

Error: permission denied to access property "print"

Can anyone suggest a workaround that will allow me to print a PDF document in Firefox without displaying it? Obviously I'm using an iframe (out of sight) for this now, but that seems to be the problem. Unfortunately there is no way to use Chrome.


**

+3
javascript firefox pdf iframe


source to share


No one has answered this question yet

Check out similar questions:

1542
How can I print JSON using JavaScript?
1535
How to print a number with commas as thousands separators in JavaScript
763
jQuery / JavaScript: Accessing Iframe Content
591
Calling JavaScript code in an iframe from the parent page
15
Firefox 19 prints PDF from JavaScript
five
Print PDF using iframe in Chrome / Firefox / IE
1
Printing pdf file from iframe
1
How do I print a PDF that is in an iframe using jQuery?
0
Print PDF in popup with Javascript
0
Firefox cannot access print iframe on the same domain



All Articles
Loading...
X
Show
Funny
Dev
Pics