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 祝福语驱散霉运的话简短