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 出阁宴祝福语姐姐简短