我希望能够在我的网站上创建一个弹出式窗口,用户可以从该窗口在网站上打印几张图像。我为此编写的代码似乎适用于Chrome和Firefox,但由于某些原因,代码无法写入IE 11中的页面。例如,下面的代码在Chrome中工作,但只是在IE 11中创建一个空白页面。有什么方法可以改变它,所以它可以在IE中工作?IE中的新窗口是空白的
<button id="sub" onclick="printme(event)">Submit</button>
<script>
function printme(evt)
{
link = "about:blank";
var pw = window.open(link, "_new");
pw.document.open();
pw.document.write("There should be writing here");
pw.document.close();
}
</script>
是否有在JavaScript控制台中的任何错误?如果你使用'link =“”;'而不是'about:blank',它会起作用吗? – Barmar 2014-10-03 04:32:01
您的代码在IE 11中可以正常工作。 – pkExec 2014-10-03 04:34:22
也适用于我 – 2014-10-03 04:37:21