• html或jsp实现打印三种方法


    
    1.使用window.print()方法
    优点:支持多浏览器
    缺点:取消打印,隐藏打印不必要的信息后再显示比较麻烦
    如下实现,可以打印当前页面
    <input name ="Button"  value="火狐谷歌打印" type="button" onclick="window.print()" />

    2.使用第三方插件的功能进行打印,eg:ireport报表插件
    优点:支持多浏览器
    缺点:实现起来比较麻烦

    3.调用ie内置打印控件IEWebBrowser实现打印功能
    优点:针对ie功能强大
    缺点:只支持ie

    <%@ page language ="java" import="java.util.*" pageEncoding="utf-8" %>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://" +request.getServerName()+":"+request.getServerPort()+path+ "/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
           <head>
                 <base href =" <%=basePath%> ">
                 <title> My JSP 'print.jsp' starting page</title >
                 <meta http-equiv ="pragma" content="no-cache" >
                 <meta http-equiv ="cache-control" content="no-cache" >
                 <meta http-equiv ="expires" content="0" >
                 <meta http-equiv ="keywords" content="keyword1,keyword2,keyword3" >
                 <meta http-equiv ="description" content="This is my page" >
                 <!-- 打印时下列方法生效 -->
                 <style media ="print" >
                <!--
                . Noprint{display: none;}
                .PageN ext{pag e-break-after:always;}
                -->
                 </style>
                 <style type ="text/css" >
                 <!--
                 .STYLE1 {font-size : 12px }
                 -->
                 </style>
           </head>
    
           <body>
                 <br>
                 <table border ='8' width="500" height="500" >
                       <tr> <td>haha</td><td>haha</td><td>haha</td><td>haha</td></tr>
                       <tr><td></ td><td></ td><td></ td><td></ td></tr>
                       <tr><td></ td><td></ td><td></ td><td></ td></tr>
                 </table>
                 <p class ="dis" align="center" >
                       <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0
                             id= "WebBrowser" width=0>
                       </OBJECT>
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(1,1) class="Noprint" type=button value=打开 />
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(2,1) class="Noprint" type=button value=关闭所有 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(4,1) class="Noprint" type=button value=另存为 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(6,1) class="Noprint" type=button value=打印 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(6,6) class="Noprint" type=button value=直接打印 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(7,1) class="Noprint" type=button value=打印预览 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(8,1) class="Noprint" type=button value=页面设置 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(10,1) class="Noprint" type=button value=属性 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(17,1) class="Noprint"       type=button value=全选 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(22,1) class="Noprint"       type=button value=刷新 >
                       <input name =Button onClick=document.all.WebBrowser.ExecWB(45,1) class="Noprint" type=button value=关闭 >
                 </p>
           </body>
    </html>



  • 相关阅读:
    as
    android 手势上下滑动头部自动隐藏View标签
    ListView 禁止滑动和点击
    Android corners 圆角属性各个版本之间兼容问题
    Android 解耦利器 EventBus
    Android 修改Activity标题样式 actionBar
    JavaScript 的写的grid Ajax加载数据 表格内增删改查 支持自定义分页大小 支持批量删除数据,支持按住ctrl多选
    Andorid 应用程序开启多进程
    比较两个文件是否相同(计算MD5效验码比较方式)
    Android 文件上传支持拍照录用录视频
  • 原文地址:https://www.cnblogs.com/fuhaots2009/p/3455216.html
Copyright © 2020-2023  润新知