js打印div指定区域内容

来源:互联网 发布:bp神经网络算法 matlab 编辑:程序博客网 时间:2024/05/22 16:00
<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>


原创粉丝点击