网页 html jsp asp 打印 页面设置 区域打印

<html>
<head>
<title>报表</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!–media=print 这个属性可以在打印时有效–>
<style media=print>
.Noprint{display:none;}<!–用本样式在打印时隐藏非打印项目–>
.PageNext{page-break-after: always;}<!–控制分页–>
</style>

<style>
.style_td
{
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.style_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;
}
.NOPRINT {
font-family: "宋体";
font-size: 9pt;
}

</style>

<script language="javascript">
      function printScreen(block)
      {       
        var value = document.all.block.innerHTML;
        var printdetail = window.open("","printDetail","");
        printdetail.document.open();
        printdetail.document.write("<HTML><head></head><BODY onload=’window.print()’>");
        printdetail.document.write("<PRE>");
        printdetail.document.write(value);
        printdetail.document.write("</PRE>");
        printdetail.document.close("</BODY></HTML>");
      }
</script>

</head>

<body >
<center class="Noprint" >
<p>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
</OBJECT>

<input type=button value=打印指定区域 onclick="printScreen(‘block’)">
<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)>
</p>
<p> <input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>
<br/>
</p>
<hr align="center" width="90%" size="1" noshade>
</center>

<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="style_tab">
<tr>
<td colspan="3" class="style_td">第1页</td>
</tr>
<tr>
<td width="29%" class="style_td">&nbsp;</td>
<td width="28%" class="style_td">&nbsp;</td>
<td width="43%" class="style_td">&nbsp;</td>
</tr>
<tr>
<td class="style_td">&nbsp;</td>
<td class="Noprint">55555555</td>
<td class="Noprint">55555555</td>
</tr>
<tr>
<td colspan="3" class="style_td"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" class="style_td"><p>这样的报表</p>
<p>对一般的要求就够了。</p></td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
</table>
<hr align="center" width="90%" size="1" noshade class="NOPRINT" >
<!–分页–>
<div class="PageNext"></div>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="style_tab">
<tr>
<td class="style_td">第2页</td>
</tr>
<tr>
<td class="style_td">看到分页了吧</td>
</tr>
<tr>
<td class="style_td">&nbsp;</td>
</tr>
<tr>
<td class="style_td">&nbsp;</td>
</tr>
<tr>
<td class="style_td"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" class="style_td"><p>这样的报表</p>
<p>对一般的要求就够了。</p></td>
<td>&nbsp;</td>
</tr>
</table></td>
</tr>
<tr>
<td>
<DIV id="block">
这是区域打印。在要打印的区域用 <DIV id="block"></DIV>包起来。
</div>
</td>

</tr>

</table>

如果要运行,请修改“ 在要打印的区域用 <DIV id="block"></DIV>包起来”中的id=block这句标识,因为会有标记重复

</body>
</html>

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/woaitiyu/archive/2008/10/27/3161248.aspx

    1.打开

        <input name="Button" onClick="document.all.WebBrowser.ExecWB(1,1)"
             type="button" value="打开">
         <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
             id="WebBrowser" width="0"></OBJECT>

    2.另存为

        <input name="Button" onClick="document.all.WebBrowser.ExecWB(4,1)"
             type="button" value="另存为">
         <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
             id="WebBrowser" width="0"></OBJECT>

    3.属性

        <input name="Button" onClick="document.all.WebBrowser.ExecWB(10,1)"
             type="button" value="属性">
         <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
             id="WebBrowser" width="0"></OBJECT>

    4.打印

        <input name="Button" onClick="document.all.WebBrowser.ExecWB(6,1)"
             type="button" value="打印">
         <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
             id="WebBrowser" width="0"></OBJECT>

    5.页面设置

        <input name="Button" onClick="document.all.WebBrowser.ExecWB(8,1)"
             type="button" value="页面设置">
         <OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0"
             id="WebBrowser" width="0"></OBJECT>

    6.刷新

        <input type="button" value="刷新" name="refresh" onclick="window.location.reload()">

    7.导入收藏

        <input type="button" name="Button" value="导入收藏夹"
             onClick="window.external.ImportExportFavorites(true,);">

    8.导出收藏

        <input type="button" name="Button" value="导出收藏夹"
             onClick="window.external.ImportExportFavorites(false,);">

    9.加入收藏

        <input name="Button" onclick="window.external.AddFavorite(location.href, document.title)"
             type="button" value="加入收藏夹">

    10.整理收藏夹

        <input name="Submit" onclick="window.external.ShowBrowserUI(OrganizeFavorites, null)"
             type="button" value="整理收藏夹">

    11.查看源文件

        <input name="Button" onclick=window.location = "view-source:" + window.location.href
             type=button" value="查看源文件">

    12.语言设置

        <input name="Button" onclick="window.external.ShowBrowserUI(LanguageDialog, null)"
             type="button" value="语言设置">

    13.前进

        <input name="Submit" onclick="history.go(1);" type="submit" value="前进">

    14.后退

        <input name="Submit" onclick="history.go(-1);" type="submit" value="后退">

     或者

        <input name="Submit" onclick="history.back();" type="submit" value="后退">

IEWebBrowser组件的execWB方法整理:

    1. <object id="WebBrowser" width="0" height="0"
             classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>

    2.调用方法

        WebBrowser.ExecWB(nCmdID, nCmdExecOpt)

    3.参数说明

        nCmdID:(其关键词都可以在浏览器的菜单里面找到对应的选项)
                        OLECMDID_OPEN = 1                                                  //打开
                        OLECMDID_NEW = 2                                                   //新建
                        OLECMDID_SAVE = 3                                                  //保存
                        OLECMDID_SAVEAS = 4                                             //另存为
                        OLECMDID_SAVECOPYAS = 5                                   //
                        OLECMDID_PRINT = 6                                                //打印
                        OLECMDID_PRINTPREVIEW = 7                                 //打印预览
                        OLECMDID_PAGESETUP = 8                                     //页面设置
                        OLECMDID_SPELL = 9                                               //
                        OLECMDID_PROPERTIES = 10                                  //属性
                        OLECMDID_CUT = 11                                                 //剪切
                        OLECMDID_COPY = 12                                              //复制
                        OLECMDID_PASTE = 13                                             //粘贴
                        OLECMDID_PASTESPECIAL = 14                               //
                        OLECMDID_UNDO = 15                                               //
                        OLECMDID_REDO = 16                                               //
                        OLECMDID_SELECTALL = 17                                     //全选
                        OLECMDID_CLEARSELECTION = 18                          //
                        OLECMDID_ZOOM = 19                                              //
                        OLECMDID_GETZOOMRANGE = 20                           //
                        OLECMDID_UPDATECOMMANDS = 21                       //
                        OLECMDID_REFRESH = 22                                        //刷新
                        OLECMDID_STOP = 23                                               //停止
                        OLECMDID_HIDETOOLBARS = 24                              //隐藏工具栏
                        OLECMDID_SETPROGRESSMAX = 25                       //
                        OLECMDID_SETPROGRESSPOS = 26                       //
                        OLECMDID_SETPROGRESSTEXT = 27                     //
                        OLECMDID_SETTITLE = 28                                        //
                        OLECMDID_SETDOWNLOADSTATE = 29                  //
                        OLECMDID_STOPDOWNLOAD = 30                          //

        nCmdExecOpt:(此参数一般情况选1即可)

                        OLECMDEXECOPT_DODEFAULT = 0                        //
                        OLECMDEXECOPT_PROMPTUSER = 1                     //
                        LECMDEXECOPT_DONTPROMPTUSER = 2              //
                        OLECMDEXECOPT_SHOWHELP = 3                          //

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>