Issue in printing iFrame in Google Chrome

时间秒杀一切 提交于 2019-12-13 02:24:36

问题


I have an iframe like

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

When I click generate button the generate function will call.In generate function i changed the src of the iframe to template2.html.

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

When I click on the print link after clicking the generate button,I want to print the iframe.

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

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

It works in Firefox. But not in chrome. In chrome the template1.html will be printed.I want to print template2.html. When I call window.print(); it will print the whole page. Please help me...


回答1:


Is it possible for you to use a separate window to print your content (like I described here https://stackoverflow.com/a/23281929/701869) ?



来源:https://stackoverflow.com/questions/20258079/issue-in-printing-iframe-in-google-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!