【发布时间】:2016-10-23 05:46:30
【问题描述】:
如何在 iOS 和 Android 的 iframe 中使用 jquery 打印 iframe 窗口。我有以下适用于 IE、Chrome 和 Firefox 的代码,但在 Android 上,它似乎正在打印顶部带有 iframe 的整个父窗口。
if (document.queryCommandSupported('print')) {
// IE and Chrome
document.execCommand('print', false, null);
} else if((navigator.userAgent.toLowerCase().indexOf("android") > -1) || (navigator.userAgent.toLowerCase().match(/(ipod|iphone|ipad)/))) {
// Android or iOS
$('iframe').contentWindow.focus();
$('iframe').contentWindow.print();
} else {
// Firefox
window.print();
}
我尝试使用 iframe 标记选择 iframe,但它似乎不起作用。请问有什么想法吗?
【问题讨论】:
标签: jquery ios iframe printing