需要帮助
我需要在单击时将 PDF 加载到 iframe
中,然后在其上调用打印对话框。
我有这样的代码:
$('.print').click(function () {
var iframe = '<iframe src="test.pdf" id="print-iframe" name="print-iframe"></iframe>';
$('body').append(iframe);
window.frames["print-iframe"].focus();
window.frames["print-iframe"].print();
});
它在 Chrome 中完美运行。但是在 Firefox 中我有这样的错误:
错误:访问属性“打印”的权限被拒绝
。
我该如何解决?谢谢!
最佳答案
在最新版本的 Firefox 上(自 19 起),您必须在 about:config
中禁用有缺陷的 native PDF 查看器 (pdf.js)。将 pdfjs.disabled
属性设置为 true
,您将看到使用您的脚本出现的打印窗口。
如果开始下载,请将 plugin.disable_full_page_plugin_for_types
属性设置为 application/pdf
。
关于javascript - Firefox 在 iframe 中打印 PDF 会引发错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15769933/