gpt4 book ai didi

javascript - Firefox 在 iframe 中打印 PDF 会引发错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:26:08 27 4
gpt4 key购买 nike

需要帮助

我需要在单击时将 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com