<script> function myPrint(obj){ var newWindow=window.open("打印窗口","_blank");//打印窗口要换成页面的url var docStr = obj.innerHTML; newWindow.document.write(docStr); newWindow.document.close(); newWindow.print(); newWindow.close(); } </script> <div id="print"> <hr /> 打印演示区域,点击打印后会在新窗口加载这里的内容! <hr /> </div> <button onclick="myPrint(document.getElementById(‘print‘))">打 印</button>
时间: 2024-11-08 23:56:36