在IE上,内部调用的是execCommand("print")方法来实现IE打印的,因为window.print方法在IE上有些问题。IE您可以试一下下面的方式
$("#click").click(function () {
spread.print();
var iframe = $("iframe")[0];
iframe.onload = function () {
var doc = iframe.contentWindow.document;
var oldFun = doc.execCommand;
doc.execCommand = function (command) {
if (command === "print") {
var imgs = $(this).find("img");
for (var i = 0; i < imgs.length; i++) {
img = imgs[i].src;
}
} else {
oldFun.apply(this, arguments);
}
}
iframe.contentWindow.print = function () {
var imgs = $(window.frames[0].document).find("img");
for (var i = 0; i < imgs.length; i++) {
img = imgs[i].src;
}
}
}
});
};
|