【发布时间】:2011-08-04 18:06:10
【问题描述】:
我有一个灯箱插件需要额外的选项 - 打印图像。 所以我做了一个小的 JS 函数来打印该图像,如下所示:
var headstr="<!DOCUMENT html><html xmlns='http://www.w3.org/1999/xhtml'><head><title></title></head><body>";
var footstr="</body>";
var newstr="<img src=\"[img-location]\" alt='courses' />";
document.body.innerHTML=headstr+newstr+footstr;
window.print();
window.location.reload();
问题是当用户按下打印按钮时,在 chrome 中它会打开一个新窗口(chrome 打印页面),并在其中显示 - print preview failed。在 Firefox 和 IE8 中它工作得很好......
【问题讨论】:
标签: javascript image google-chrome printing