<HTML>
<HEAD>
<TITLE> 我的课程表 </TITLE>
<SCRIPT language=javascript>
function printsetup()
{
// 打印页面设置
wb.execwb(8,1);
}
function printpreview()
{
var ht1 = document.getElementById( "h ");
ht1.style.display= "none ";//隐藏不必打印的部分,该隐藏只在预览中有效,真正打印时要用css控制
wb.execwb(7,1); // 打印页面预览
ht1.style.display= " "; //预览完再将隐藏的部分显示出来
}
function printit()
{
if (confirm( '确定打印吗? '))
{
wb.execwb(6,6);
}
}
</script>
<style type= "text/css " media=print>
.noprint{display : none } //不打印
</style>
</HEAD>
<BODY>
<!-- div h 中的内容不打印 -->
<DIV id= "h " align=center class= "noprint ">
<OBJECT id=wb height=0 width=0 classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2> </OBJECT>
<INPUT onclick=javascript:printit() type=button value=打印 />
<INPUT onclick=javascript:printsetup(); type=button value=打印页面设置 />
<INPUT onclick=javascript:printpreview(); type=button value=打印预览/>
<br> alkdjflkasdjflkajdflkadjiouepirulksjdfkj预览时不显示 </br>
</DIV>
可以以页面预览中显示
要打印的正文
</BODY>
</HTML>
------------------------------方法二-------------------
//注此方法只打印gridview中的數據
<script language= "javascript ">
function PrintNote()
{
var PrintWin=window.open( 'about:blank ', 'Print ');
PrintWin.document.write( ' <object id= "WebBrowser " width=0 height=0 classid= "CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 "> </object> ' + document.all( "PrintContent ").innerHTML);
PrintWin.document.all.WebBrowser.ExecWB(7,1);
PrintWin.close();
}
</script>
<input id= "Button5 " type= "button " value= "列印 " onclick= "javascript:PrintNote(); " /> <br />
將gridview放於div中