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


source to share





All Articles