繁体   English   中英

尝试通过iframe打印pdf,在Firefox中出现错误

[英]Trying to print pdf through iframe, get error in Firefox

在Chrome中工作正常,但在Firefox中出现此错误:

Error: Permission denied to access property 'print'

我的代码:

<iframe src="http://domain.com/wp-content/uploads/2014/08/CV.pdf" id="PDFtoPrint"></iframe>
<a class="" href="#" title="Print CV" onclick="document.getElementById('PDFtoPrint').focus();document.getElementById('PDFtoPrint').contentWindow.print();"></a>

我在firefox论坛上看到了这个错误。解决了吗?

还有其他解决方案吗?

谢谢!

编辑:在IE上我收到此错误:

SCRIPT65535: Invalid calling object

解决了:

<script>
    function for_print(){
      window.frames["printf"].focus();
      window.frames["printf"].print();
      var newWin = window.frames['printf'];
    }
</script>

<iframe style="display:none;" id="printf" name="printf" src="demo.html"></iframe>
<iframe src="demo.html" id="PDFtoPrint" style="display:none;"></iframe>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM