Home > Web Front-end > JS Tutorial > body text

Analysis of JavaScript calling browser print function example_javascript skills

WBOY
Release: 2016-05-16 15:50:09
Original
1556 people have browsed it

The example in this article describes how JavaScript calls the browser's print function. Share it with everyone for your reference. The details are as follows:

1. Universal type, supports IE, Firefox, Chrome...

Copy code The code is as follows:
window.print();

2. Only supports IE printing:

<script>
var print=function(){
/**
 * WebBrowser.ExecWB(1,1) 打开
 * Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口
 * Web.ExecWB(4,1) 保存网页
 * Web.ExecWB(6,1) 打印
 * Web.ExecWB(7,1) 打印预览
 * Web.ExecWB(8,1) 打印页面设置
 * Web.ExecWB(10,1) 查看页面属性
 * Web.ExecWB(15,1) 好像是撤销,有待确认
 * Web.ExecWB(17,1) 全选
 * Web.ExecWB(22,1) 刷新
 * Web.ExecWB(45,1) 关闭窗体无提示 
 */
document.getElementById('printer').ExecWB(6,1);
}
</script>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" id="printer"
  height="0" width="0"></OBJECT>
<button onclick="print();">打印</button>

Copy after login

3. Control the print display area and paging style:

.noprint {
  display: none;
}
.nextpage {
  page-break-after: always;
}

Copy after login

I hope this article will be helpful to everyone’s JavaScript programming design.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template