【发布时间】:2017-03-08 16:55:14
【问题描述】:
这是我的 jquery 代码:
jQuery('.print_btn').hide();
var contents = document.getElementById("print_page").innerHTML;
var frame1 = document.createElement('iframe');
frame1.name = "frame1";
frame1.style.position = "absolute";
frame1.style.top = "-1000000px";
document.body.appendChild(frame1);
var frameDoc = (frame1.contentWindow) ? frame1.contentWindow : (frame1.contentDocument.document) ? frame1.contentDocument.document : frame1.contentDocument;
frameDoc.document.open();
frameDoc.document.write('<html><head><title></title>');
frameDoc.document.write('</head><body>');
frameDoc.document.write(contents);
frameDoc.document.write('</body></html>');
frameDoc.document.close();
setTimeout(function () {
frameDoc.focus();
frameDoc.print();
document.body.removeChild(frame1);
}, 500);
jQuery('.print_btn').show();
return false;
我在谷歌上搜索,但我没有找到任何解决方案,所以我发布了这个问题。 我有一个带有图像和打印按钮的弹出窗口,我想在单击打印按钮时打印图像。 这在网络浏览器上工作正常意味着在桌面上,但它正在打印整个页面和弹出图像,而在 ipad 上它什么也没打印。
为什么会这样,我不知道请帮帮我。
【问题讨论】:
标签: javascript jquery html css