我该如何打印iframe内容

时间:2014-09-05 09:13:57

标签: javascript iframe

我想要打印iframe内容而我无法做到,我发现the url我是新的舞会演员,所以我没有理解这个问题和答案请解释我一些简单的问题/> 提前谢谢

1 个答案:

答案 0 :(得分:2)

这是:

你的iframe:

<iframe id="printf" name="printf"></iframe>

印刷:

window.frames["printf"].focus();
window.frames["printf"].print();
顺便说一句,下次尝试以更好的方式解释您的问题(发布代码可以帮助)=)

参考Javascript Print iframe contents only

编辑:

由于OP表示没有工作,我引用了参考文献中链接的测试页:

Print an iframe

你也可以尝试这个功能(同样的参考,不同的海报):

//id is the  id of the iframe
function printFrame(id) {
            var frm = document.getElementById(id).contentWindow;
            frm.focus();// focus on contentWindow is needed on some ie versions
            frm.print();
            return false;
}
相关问题