gpt4 book ai didi

javascript - 如何打印 iframe 内容

转载 作者:行者123 更新时间:2023-12-02 17:01:18 25 4
gpt4 key购买 nike

我想打印iframe内容但做不到,我发现the url我是一名新程序员,所以我不明白问题和答案,请向我解释一些简单的
提前致谢

最佳答案

这里是:

您的 iframe:

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

打印:

window.frames["printf"].focus();
window.frames["printf"].contentWindow.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;
}

关于javascript - 如何打印 iframe 内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25682414/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com