Javascript仅打印iframe内容这是我的代码<script>var body = "dddddd" var script = "<script>window.print();</scr'+'ipt>";var newWin = $("#printf")[0].contentWindow.document; newWin.open();newWin.close();$("body",newWin).append(body+script);</script><iframe id="printf"></iframe>这可以,但它打印父页面,我如何让它只打印iframe?
3 回答
不负相思意
TA贡献1777条经验 获得超10个赞
简单的方法(在ie7 +,firefox,Chrome,safari上测试)就是这样
//id is the id of the iframefunction printFrame(id) { var frm = document.getElementById(id).contentWindow; frm.focus();// focus on contentWindow is needed on some ie versions frm.print(); return false;}
添加回答
举报
0/150
提交
取消