参考:http://www.chinaz.com/design/2008/0523/29743.shtml
一.实例
(1)css <style media="print" type="text/css">
.Noprint { DISPLAY: none }
.PageNext{ PAGE-BREAK-AFTER: always }
</style>
(2)js
<script type="text/javascript">
$(function () {
$("#test").click(function () {
window.print();
});
});
</script>
(3)aspx
<div id="select" class="Noprint">
节假日名称
<sjt:HolidayDropDownList ID="ddlHoliday" runat="server" Width="200px" CssClass="ddlCss" />
节假日第几天
<sjt:HolidayDayDropDownList runat="server" ID="ddlHolidayDay" Width="100px" CssClass="ddlCss" />
<asp:Button runat="server" ID="btnSearch" Text="查 询" Width="70px" />
<asp:Button runat="server" ID="test" Text="打印" Width="70px" />
</div>
<div id="main" class="PageNext">
<iframe name="frChart" id="frTarget" runat="server" src="" scrolling="yes" frameborder="0"></iframe>
</div>
二.解释:
(1)两个关键的CSS
<style media="print">
.Noprint { DISPLAY: none }
.PageNext{ PAGE-BREAK-AFTER: always }
</style>
第一个在不需要打印的标签上添加(子标签也将不被打印),
第二个在需要换行的标签处添加(该标签所表示的内容将在当前打印的一页内)
(2)接下来通过调用最基本的js语句
window.print()就可实现页面局部打印了!