如何在Firefox中打印iframe PDF? [英] How print a Iframe PDF in Firefox?

查看:179
本文介绍了如何在Firefox中打印iframe PDF?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Yes I have seen other questions about this too, but they have not helped me, so this is my code.

$("#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中则无效.

this code works in google chrome, but in firefox it didn't.

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

first it creates the pdf in the server, then it generates in the page, and then it waits 1 second and then prints it, but it doesnt' work in firefox, if i discomment the commented line, then firefox asks if i want to stop more dialog windows? can you help me?

推荐答案

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

It seems to me that the browser you are checking will be out of date, as I have checked the following code in all browsers and it works fine. I checked in Chrome, Firefox and Opera, and I also checked with IE and it worked well in all browsers.

因此,请先更新您的浏览器.

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

这篇关于如何在Firefox中打印iframe PDF?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆