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 送给学长毕业祝福语简短