js print打印网页指定区域内容的简单实例
实例如下:
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=utf-8"/>
<title>jsprint打印网页指定区域内容的简单实例</title>
</head>
<script>
functionmyPrint(obj){
varnewWindow=window.open("打印窗口","_blank");
vardocStr=obj.innerHTML;
newWindow.document.write(docStr);
newWindow.document.close();
newWindow.print();
newWindow.close();
}
</script>
<divid="print">
<hr/>
打印演示区域,点击打印后会在新窗口加载这里的内容!
<hr/>
</div>
<buttononclick="myPrint(document.getElementById('print'))">打印</button>
</html>
以上就是小编为大家带来的jsprint打印网页指定区域内容的简单实例全部内容了,希望大家多多支持毛票票~