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打印网页指定区域内容的简单实例全部内容了,希望大家多多支持毛票票~
热门推荐
10 广西考试祝福语结婚简短
11 猪年祝福语简短小孩
12 元旦祝福语送长辈简短
13 恭喜二宝祝福语简短
14 祝福语暖心话简短
15 国庆中秋祝福语简短兄弟
16 朋友订婚的祝福语简短
17 送弟弟中秋祝福语简短
18 爱生日祝福语简短独特