This article introduces a detailed example of using HTML to realize the paging printing function. Some paging printing that you do not want to print can be controlled by using this type of style. It is invalid when not printing.
<html>
<head>
<title>页面打印</title>
<!--media=print 这个属性在打印时有效 有些不想打印出来的分页打印的都可以应用这类样式进行控制 在非打印时是无效的(可从打印预览中看到效果)-->
<style media=print>
/* 应用这个样式的在打印时隐藏 */
.noPrint {
display: none;
}
/* 应用这个样式的,从那个标签结束开始另算一页,之后在遇到再起一页,以此类推 */
.page {
page-break-after: always;
}
</style>
<!-- 这个是普通样式 -->
<style type="text/css">
.tab td {
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.tab {
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.hr {
font-family: "宋体";
font-size: 9pt;
}
</style>
<script language="JavaScript" type="text/JavaScript">
var hkey_root, hkey_path, hkey_key;
hkey_root = "HKEY_CURRENT_USER";
hkey_path = "//Software//Microsoft//Internet Explorer//PageSetup//";
//这个是用来设置打印页眉页脚的,你可以设置为空或者其它
try{
var RegWsh = new ActiveXObject("WScript.Shell");
hkey_key="header";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key, "&w&b页码,&p/&P");
hkey_key="footer";
RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"");
}catch(e){
alert(e.description());
}
</script>
</head>
<body bgcolor="white">
<table cellspacing="0" cellpadding="0" width="100%" align="center" border="0">
<thead class="noPrint">
<tr>
<td align="center" colspan="3">
<center class="NoPrint">
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0></OBJECT>
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6) />
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1) />
<input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1) />
<!--
关于这个组件还有其他的用法,列举如下:
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) 关闭窗体无提示
-->
</center>
</td>
</tr>
</thead>
<tr>
<td align="center" colspan="3" style="font-size: 24px">
<b>报告印章申请表</b>
</td>
</tr>
<tr>
<td align="left" colspan="2">编号:A002 </td>
<td align="right"> </td>
</tr>
<tr>
<td colspan="3">
<table class="tab" cellSpacing="0" cellPadding="0" width="100%">
<tr align="center" height="23">
<td width="10%" height="23"><b>编号</b></td>
<td width="5%"><b>份数</b></td>
<td width="12%"><b>项目/级别编号</b></td>
<td width="12%"><b>单位</b></td>
<td width="12%"><b>项目名称</b></td>
<td width="12%"><b>工程地点</b></td>
<td width="12%"><b>检测项目</b></td>
<td width="7%"><b>单价</b></td>
<td width="8%"><b>数量</b></td>
<td width="10%"><b>总价</b></td>
</tr>
<tr style="font-size: 13px" align="center" height="23">
<td>A14785 </td>
<td>5 </td>
<td>A1546/8975 </td>
<td>中国广东广州 </td>
<td>BRT工程 </td>
<td>广州天河 </td>
<td>BRT工程 </td>
<td>¥999999999.99</td>
<td>20 </td>
<td>20*¥999999999.99 </td>
</tr>
<tr align="center" height="23">
<td colspan="2">备注</td>
<td colspan="8"> </td>
</tr>
</table>
</td>
</tr>
</table>
<hr class="noprint" width="100%" size="2"/>
<p class="page"></p>
<table class="tab" cellSpacing="0" cellPadding="0" width="100%">
<tr align="center" height="23">
<td width="10%" height="23"><b>编号</b></td>
<td width="5%"><b>份数</b></td>
<td width="12%"><b>项目/级别编号</b></td>
<td width="12%"><b>单位</b></td>
<td width="12%"><b>项目名称</b></td>
<td width="12%"><b>工程地点</b></td>
<td width="12%"><b>检测项目</b></td>
<td width="7%"><b>单价</b></td>
<td width="8%"><b>数量</b></td>
<td width="10%"><b>总价</b></td>
</tr>
<tr style="font-size: 13px" align="center" height="23">
<td>A14785 </td>
<td>5 </td>
<td>A1546/8975 </td>
<td>中国广东广州 </td>
<td>BRT工程 </td>
<td>广州天河 </td>
<td>BRT工程 </td>
<td>¥999999999.99</td>
<td>20 </td>
<td>20*¥999999999.99 </td>
</tr>
<tr align="center" height="23">
<td colspan="2">备注</td>
<td colspan="8"> </td>
</tr>
</table>
<p class="page"></p>
<table class="tab" cellSpacing="0" cellPadding="0" width="100%">
<tr align="center" height="23">
<td width="10%" height="23"><b>编号</b></td>
<td width="5%"><b>份数</b></td>
<td width="12%"><b>项目/级别编号</b></td>
<td width="12%"><b>单位</b></td>
<td width="12%"><b>项目名称</b></td>
<td width="12%"><b>工程地点</b></td>
<td width="12%"><b>检测项目</b></td>
<td width="7%"><b>单价</b></td>
<td width="8%"><b>数量</b></td>
<td width="10%"><b>总价</b></td>
</tr>
<tr style="font-size: 13px" align="center" height="23">
<td>A14785 </td>
<td>5 </td>
<td>A1546/8975 </td>
<td>中国广东广州 </td>
<td>BRT工程 </td>
<td>广州天河 </td>
<td>BRT工程 </td>
<td>¥999999999.99</td>
<td>20 </td>
<td>20*¥999999999.99 </td>
</tr>
<tr align="center" height="23">
<td colspan="2">备注</td>
<td colspan="8"> </td>
</tr>
</table>
</body>
</html>The above is the detailed content of Detailed example of using html to implement paging printing function. For more information, please follow other related articles on the PHP Chinese website!
The Future of HTML: Evolution and Trends in Web DesignApr 17, 2025 am 12:12 AMThe future of HTML is full of infinite possibilities. 1) New features and standards will include more semantic tags and the popularity of WebComponents. 2) The web design trend will continue to develop towards responsive and accessible design. 3) Performance optimization will improve the user experience through responsive image loading and lazy loading technologies.
HTML vs. CSS vs. JavaScript: A Comparative OverviewApr 16, 2025 am 12:04 AMThe roles of HTML, CSS and JavaScript in web development are: HTML is responsible for content structure, CSS is responsible for style, and JavaScript is responsible for dynamic behavior. 1. HTML defines the web page structure and content through tags to ensure semantics. 2. CSS controls the web page style through selectors and attributes to make it beautiful and easy to read. 3. JavaScript controls web page behavior through scripts to achieve dynamic and interactive functions.
HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AMHTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.
HTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AMHTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.
From Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AMHTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.
Understanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AMWebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.
The Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AMThe role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.
HTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AMHTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

Dreamweaver CS6
Visual web development tools






