利用JavaScript实现打印(Web打印)
JS打印函数:
<a href="#" onClick="window.print()">打印</a>
打印的内容控制是不是像【孟子E章】(谢谢),说的那样:
<html>
<head>
<style type="text/css" media=print>
.noprint{display : none }
</style>
</head>
<body>
<div class="noprint">不打印的部分</div>
<div>打印的部分</div>
<div class="noprint">不打印的部分</div>
</body>
</html>
运用上就是这样的:
<html>
<head>
<style type="text/css" media=print>
.noprint{display : none }
</style>
</head>
<body>
<div class="noprint">不打印的部分</div>
<div>
<div style="text-align: center">
<table width="90%" bgcolor="white" class="tableBorder" cellpadding="0" cellspacing="0" align="center">
<tr>
<td style="text-align: center; width: 917px;" align="center">
<div style="text-align:center; margin-left:20px; margin-top:20px;">
<asp:Table ID="Table1" border="1" cellpadding="0" cellspacing="0" runat="server" Width="100%" >
<asp:TableHeaderRow><asp:TableHeaderCell ColumnSpan="15">基本信息</asp:TableHeaderCell></asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell Width="62">姓名:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="username" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">职工编号:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usernum" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">出生日期:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="userbirthdate" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">
性别:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usersex" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">民族:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usernation" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">在册标识:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usermark" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">介绍人:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="userintro" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell >
<asp:Label ID="probationtime" runat="server" Text="Label"></asp:Label></asp:TableCell>
</asp:TableRow>
<asp:TableHeaderRow><asp:TableHeaderCell ColumnSpan="15">扩展信息</asp:TableHeaderCell></asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell>教<br />育<br />简<br />历</asp:TableCell>
<asp:TableCell ColumnSpan="14">
<asp:GridView ID="eduresume" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="QSRQ" HeaderText="起始日期"/>
<asp:BoundField DataField="ZZRQ" HeaderText="终止日期"/>
<asp:BoundField DataField="BYYX" HeaderText="毕业院校"/>
<asp:BoundField DataField="SXZY" HeaderText="所学专业"/>
<asp:BoundField DataField="XZ" HeaderText="学制"/>
<asp:BoundField DataField="BYFS" HeaderText="毕业方式"/>
<asp:BoundField DataField="BZ" HeaderText="备注"/>
</Columns>
</asp:GridView>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</td>
</tr>
</table>
</div>
<div class="noprint">不打印的部分</div>
</body>
</html>
是这样的吗???要打印的是内置有GridVIew的Table控件。。。
<a href="#" onClick="window.print()">打印</a>
打印的内容控制是不是像【孟子E章】(谢谢),说的那样:
<html>
<head>
<style type="text/css" media=print>
.noprint{display : none }
</style>
</head>
<body>
<div class="noprint">不打印的部分</div>
<div>打印的部分</div>
<div class="noprint">不打印的部分</div>
</body>
</html>
运用上就是这样的:
<html>
<head>
<style type="text/css" media=print>
.noprint{display : none }
</style>
</head>
<body>
<div class="noprint">不打印的部分</div>
<div>
<div style="text-align: center">
<table width="90%" bgcolor="white" class="tableBorder" cellpadding="0" cellspacing="0" align="center">
<tr>
<td style="text-align: center; width: 917px;" align="center">
<div style="text-align:center; margin-left:20px; margin-top:20px;">
<asp:Table ID="Table1" border="1" cellpadding="0" cellspacing="0" runat="server" Width="100%" >
<asp:TableHeaderRow><asp:TableHeaderCell ColumnSpan="15">基本信息</asp:TableHeaderCell></asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell Width="62">姓名:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="username" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">职工编号:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usernum" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">出生日期:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="userbirthdate" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">
性别:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usersex" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">民族:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usernation" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">在册标识:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="usermark" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell Width="62">介绍人:</asp:TableCell>
<asp:TableCell Width="62">
<asp:Label ID="userintro" runat="server" Text="Label"></asp:Label></asp:TableCell>
<asp:TableCell >
<asp:Label ID="probationtime" runat="server" Text="Label"></asp:Label></asp:TableCell>
</asp:TableRow>
<asp:TableHeaderRow><asp:TableHeaderCell ColumnSpan="15">扩展信息</asp:TableHeaderCell></asp:TableHeaderRow>
<asp:TableRow>
<asp:TableCell>教<br />育<br />简<br />历</asp:TableCell>
<asp:TableCell ColumnSpan="14">
<asp:GridView ID="eduresume" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:BoundField DataField="QSRQ" HeaderText="起始日期"/>
<asp:BoundField DataField="ZZRQ" HeaderText="终止日期"/>
<asp:BoundField DataField="BYYX" HeaderText="毕业院校"/>
<asp:BoundField DataField="SXZY" HeaderText="所学专业"/>
<asp:BoundField DataField="XZ" HeaderText="学制"/>
<asp:BoundField DataField="BYFS" HeaderText="毕业方式"/>
<asp:BoundField DataField="BZ" HeaderText="备注"/>
</Columns>
</asp:GridView>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</td>
</tr>
</table>
</div>
<div class="noprint">不打印的部分</div>
</body>
</html>
是这样的吗???要打印的是内置有GridVIew的Table控件。。。
...全文
相关推荐
利用javascript实现web页面中指定区域打印
最近做到了web页面课程表打印时,上网找了一些资料,最后使用了下面的方法实现了我需要的功能。将需要打印的课程表的table放入div标签中,然后指定出需要打印的区域,最后调用window.print打印指定内容。 示例代码(代码中有些内容已省略) 代码如下:function preview() { bdhtml = window.document.body[removed]; sprnstr = “<!–startprint–>”; eprnstr = “<!–endprint–>”; prnhtml = bdhtml.substr(bdhtml.indexOf(sp
Printer_js_css 纯js实现web打印服务,完全兼容
Printer_js_css 纯js实现web打印服务,可兼容各种浏览器,已应用于项目中,送给大家进行参考,希望有帮助
纯js在线WEB打印设计模块
纯js在线WEB打印设计模块,用来设计在线快递模板,打印配货单模板很不错.
pdf.js Demo 纯js实现PDF在线预览及打印
pdf.js Demo 纯js实现PDF在线预览及打印 可控制页面缩放 打开本地文件
PDF.js在线预览打印
PDF.js在线预览、打印及下载(纯js实现PDF在线预览、打印及下载),可控制预览、打印及下载等按钮操作;


