【问题标题】:How print a Iframe PDF in Firefox?如何在 Firefox 中打印 iframe PDF?
【发布时间】:2012-04-15 20:33:32
【问题描述】:

是的,我也看到了其他关于此的问题,但他们没有帮助我,所以这是我的代码。

$("#raspe4atat_<?= $ui->item_id ?>").click(function(){
    $.ajax({
        url: "/raspe4atat/<?= $ui->item_id ?>",
        type: "GET",
        success: function(){
            $.ajax({
                url: "/iframe/<?= $ui->item_id ?>",
                type: "GET",
                success: function(r){
                    $("#not_enough_money_<?= $ui->item_id ?>").append(r);
                    setTimeout(function(){
                        document.getElementById('pdf_<?= $ui->item_id ?>').contentWindow.print();
                        //window.frames['iframe_<?= $ui->item_id ?>'].print();
                    }, 1000);
                }
            });
        }
    });
    return false;
});

这是 iframe:

<iframe name="iframe_<?= $ui->item_id ?>" style="position: absolute; top: -1000px;" id="pdf_<?= $ui->item_id ?>" src="<?= base_url().'pdf/'."coupon_info_".$ui->user_id.'.pdf' ?>" width="0" height="0">
</iframe>

此代码在 google chrome 中有效,但在 firefox 中无效。

首先它在服务器中创建 pdf,然后在页面中生成,然后等待 1 秒然后打印它,但它在 firefox 中不起作用,如果我取消注释行,然后 firefox 询问我是否想要停止更多对话窗口?你能帮帮我吗?

【问题讨论】:

  • 你能发布答案吗?

标签: javascript pdf firefox printing


【解决方案1】:

在我看来,您正在检查的浏览器将过时,因为我已经在所有浏览器中检查了以下代码并且它工作正常。 我检查了 Chrome、Firefox 和 Opera,我还检查了 IE,它在所有浏览器中都运行良好。

所以请先更新您的浏览器。

window.frames['iframe_1'].focus();
window.frames['iframe_1'].print();

【讨论】:

    猜你喜欢
    • 2013-05-12
    • 2014-10-19
    • 1970-01-01
    • 2023-03-10
    • 2016-01-20
    • 1970-01-01
    • 1970-01-01
    • 2012-11-19
    • 1970-01-01
    相关资源
    最近更新 更多