.innerhtml在第一次点击时总是失败但在下次点击时起作用

时间:2016-08-24 21:14:56

标签: javascript

我有一个点击按钮时运行的javascript,它会生成一个新的打印窗口。

此脚本应该将图片添加到我的文档中,但由于某种原因,它在第一次单击时无法执行此操作。在IE和Chrome上如果我关闭窗口并再次打开它,则会出现图片。

在FF上,窗户似乎被卡在永恒的装载中。

var PrintingWindow = window.open("","View Proof of Pricing",
"toolbar,width=800,height=600,scrollbars,resizable,menubar");
PrintingWindow.document.open();
PrintingWindow.document.write(PrintingHTML);
PrintingWindow.document.getElementById('imageDiv').setAttribute("align", "center");

PrintingWindow.document.getElementById('imageDiv').innerHTML = "<a href='#'><img src='someURL' border='1' width='300' height='170'/></a>"

0 个答案:

没有答案
相关问题