我有一个lightbox插件,需要额外的选项 - 打印图像。 所以我做了打印图像如下一点的JS函数:window.print()javascript does not get previewed in chrome
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它会打开一个新窗口(铬打印页),并在其中它说 - print preview failed。在Firefox和IE8中,它工作得很好...
我加一个结束的HTML标签,但有什么不妥:
该结构适用于整个页面,但您将其插入到body \ document.body.innerHTML'中。所以,你已经有了'
哦,对了,我该怎么办文件= headstr + +中newstr footstr?我想要它,因为它也删除了现有的标题内容 – Nir