在Google Chrome中打印iFrame时出现问题

时间:2013-11-28 05:01:47

标签: javascript jquery html google-chrome iframe

我有一个iframe

<iframe id="Frame1" name="Frame1" style="width: 810px;overflow:hidden;height:525px;border:none;"src="templates/template1.html">
</iframe>

当我点击生成按钮时 generate函数将调用。在generate函数中,我将iframe的src更改为template2.html。

    <input type="button"  id="btngenerate" onclick="Generate();"/>
    <a id="print" onclick="OnPrint();">Print</a>

单击生成按钮后单击打印链接时,我想打印iframe。

    function generate()
    {
        var billPath = "templates/template2.html";
        $("#Frame1").attr("src", billPath);
    }

    function onPrint()
    {
        window.frames["Frame1"].window.focus();
        window.frames["Frame1"].window.print(); 
    }

适用于Firefox。但不是铬。 在chrome中将打印template1.html。我想打印template2.html。 当我拨打window.print();时,它将打印整个页面。 请帮帮我......

1 个答案:

答案 0 :(得分:0)

您是否可以使用单独的窗口打印内容(如我在此处所述https://stackoverflow.com/a/23281929/701869)?