tinguo002

 

WEB 打印,去页码、隐藏打印按钮

详细参考:http://www.cnblogs.com/aidd2008/archive/2012/04/25/2469994.html

JSP代码如下:

<%@page import="java.net.URLDecoder"%>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
 String path = request.getContextPath();
 String basePath = request.getScheme() + "://"
   + request.getServerName() + ":" + request.getServerPort()
   + path + "/";
 String params = request.getParameter("params");
 params = URLDecoder.decode(params, "UTF-8");
 String[] arr = new String[8];
 if (params != null) {
  arr = params.split(",");
 }
 request.setAttribute("arr", arr);
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<base href="<%=basePath%>">

<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">
<!--
 <link rel="stylesheet" type="text/css" href="styles.css">
 -->
<style media=print>
.Noprint {
 display: none;
}

.PageNext {
 page-break-after: always;
}

</style>
<style type="text/css">
.helpSpan{ 
 margin-left:20px;
 cursor:pointer;
 display:inline-block;
 color:blue;
}
</style>
<script type="text/javascript" src="<%=path%>/js/jquery-1.8.3.min.js"></script>
<title>打印单</title>
<object id="WebBrowser" width=0 height=0 classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></object>
<link rel="stylesheet" type="text/css"
 href="css/gzjrzcjys/editFrame.css" />
 <script type="text/javascript">
  function print1(){
   document.all.WebBrowser.ExecWB(6,6);
  }
  function wOpen(){
   $("span.open").hide();
   $("span.close").show();
   $("#helpContent").show();
  }
  function wClose(){
   $("span.open").show();
   $("span.close").hide();
   $("#helpContent").hide();
  }
   var hkey_root, hkey_path, hkey_key;
         hkey_root = "HKEY_CURRENT_USER";
         hkey_path = "\\software\\Microsoft\\Internet Explorer\\PageSetup\\";
         //设置网页打印的页眉页脚边距为空
         function pagesetup_null() {
             try {
                 var RegWsh = new ActiveXObject("WScript.Shell");
                 hkey_key = "header";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
                 hkey_key = "footer";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
                 hkey_key = "margin_left";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.0");
                 hkey_key = "margin_right";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.0");
                 hkey_key = "margin_top";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.0");
                 hkey_key = "margin_bottom";
                 RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "0.0");
             } catch (e) {
              alert(e);
             }
         }

  $(document).ready(function(){
   pagesetup_null();
  });
 </script>
</head>

<body>
 <div id="frame">
  <div id="frame_title">线下资金转入申请</div>
  <div id="frame_content">

   <table class="content">
    <tr>
     <th>收款银行:</th>
     <td><%=arr[0]%></td>
     <th>收款方全称:</th>
     <td><%=arr[1]%></td>
    </tr>
    <tr>
     <th>收款方银行账号:</th>
     <td><%=arr[2]%></td>
     <th>充值码:</th>
     <td><%=arr[3]%>(填写在备注栏)</td>
    </tr>
    <tr>
     <th>汇款银行:</th>
     <td><%=arr[4]%></td>
     <th>汇款方全称:</th>
     <td><%=arr[5]%></td>
    </tr>
    <tr>
     <th>汇款账号:</th>
     <td><%=arr[6]%></td>
     <th>汇款金额:</th>
     <td><%=arr[7]%>&nbsp;元</td>
    </tr>
   </table>


  </div>
  <div id="frame_bottom" class="Noprint">
   <a href="javascript:void(0)" class="button_toRound"><span
    style="font-size:14px;"
    onclick="print1()" class="Noprint">【打印】</span>
   </a>
  </div>
  <div style="padding:12px 5px;background-color:#ffffff" class="Noprint">
   备注: 请到网银或者银行办理转账业务,转账汇款时,信息必须如实填写,以避免无法如实到账而给您的投资造成损失!</div>
 </div>

 <div style="width:750px;margin:auto;margin-top:150px;" class="Noprint">
  <div>友情链接:</div>
  <div>
   <table class="content">
    <tr>
     <td><a href="http://www.boc.cn/" target="_blank">中国银行</a>
     </td>
     <td><a href="http://www.ccb.com/cn/home/index.html"
      target="_blank">建设银行</a>
     </td>
     <td><a href="http://www.icbc.com.cn/icbc/" target="_blank">工商银行</a>
     </td>
     <td><a href="http://www.abchina.com/cn/" target="_blank">农业银行</a>
     </td>
    </tr>
    <tr>
     <td><a href="http://www.cebbank.com/Site/ceb/cn"
      target="_blank">光大银行</a>
     </td>
     <td><a
      href="http://www.bankcomm.com/BankCommSite/cn/default.html"
      target="_blank">交通银行</a>
     </td>
     <td><a href="http://www.cib.com.cn/cn/index.html"
      target="_blank">兴业银行</a>
     </td>
     <td><a href="http://www.psbc.com/portal/zh_CN/index.html"
      target="_blank">邮政储蓄</a>
     </td>
    </tr>

   </table>
  </div>
 </div>
 <div style="width:750px;margin:auto;margin-top:50px;" class="Noprint">
  <div>帮助:点击【打印】按钮没有反应。<span class="open helpSpan"  onclick="wOpen()">&gt;&gt;&gt;展开</span><span onclick="wClose()" class="close helpSpan" style="display:none;">&lt;&lt;&lt;收起</span></div>
  <div id="helpContent" style="display:none;">
   <p>需要将本站点添加为信任站点。共分为三步。</p>
   <p>第一步:打开IE浏览器的 Intenet选项</p>
   <div><img src="<%=path%>/images/open_Intenet_ie8.jpg"/></div>
   <p>或者</p>
   <div><img src="<%=path%>/images/open_Intenet_ie11.jpg"/></div>
   <p style="margin-top:20px;">第二步:添加信任站点</p>
   <div><img src="<%=path%>/images/setXinren_ie11.jpg"/></div>
   <p style="margin-top:20px;">第三步:允许控件运行</p>
   <div><img src="<%=path%>/images/setActive.jpg"/></div>
  </div>
 </div>
 <!--endprint-->
</body>
</html>

代码中所需图片如下:








欢迎大家访问我的个人网站 萌萌的IT人

posted on 2014-06-28 21:49 一堣而安 阅读(433) 评论(0)  编辑  收藏 所属分类: js_css


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

常用链接

留言簿(1)

随笔分类

随笔档案

收藏夹

搜索

最新评论

阅读排行榜

评论排行榜