windows .print()在ie中不工作,并且已经尝试了适当的修复

window.print() not working in ie and already tried proper fixes

本文关键字:print ie 工作 windows      更新时间:2023-09-26

我想打印整个页面时,一个按钮被点击。我正在使用window.print(),但它不适合ie。我在谷歌上搜索了一个解决方案,但没有任何帮助。也许有人知道我做错了什么。

MyCode :

$('#PrintTool').click(function () {
var printVal = document.documentElement.innerHTML;
var newWin = window.open();
newWin.document.write(printVal);
newWin.document.close();
newWin.focus();
newWin.print();
newWin.close();
});

我希望你能帮助我

checkout: window.print()在IE中不工作

工作示例:http://jsfiddle.net/Q5Xc9/1/

<html>
<head>
<script type="text/javascript">
  function openWin()
  {
    var myWindow=window.open('','','width=200,height=100');
    myWindow.document.write("<p>This is 'myWindow'</p>");
    myWindow.document.close();
    myWindow.focus();
    myWindow.print();
    myWindow.close();
  }
</script>
</head>
<body>
<input type="button" value="Open window" onclick="openWin()" />
</body>
</html>