posts - 9,  comments - 11,  trackbacks - 0
JS实现区域打印,去页眉页脚
http://hi.baidu.com/supersolon/blog/item/7a52c6562cebb9030df3e3e5.html

//此网页内容实现了用JS的方法进行区域打印,去除页眉页脚,添加控件进行预览等功能。

Title

<%@ page language="java" contentType="text/html;charset=gbk"
import="java.util.Date"%>
<%@ taglib uri="http://displaytag.sf.net" prefix="display"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html>

<head>
<title>处理用车申请</title>
<fmt:setBundle basename="MyResource" scope="session" />
<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 href="<fmt:message key='StylePath' />style.css" rel="stylesheet"
   type="text/css">
<script type="text/javascript"
   src="<fmt:message key='JavaScriptPath' />common.js"></script>
<script language="javascript"
   src="<fmt:message key='JavaScriptPath' />meizzDate.js"></script>
<script language="JavaScript"
   src="<fmt:message key='JavaScriptPath' />GetDate.js"></script>

<style type="text/css" media="print">
   .noPrint{display:none}
</style>

<script language="javascript">

var hkey_root,hkey_path,hkey_key;
    var hkey_root = "HKEY_CURRENT_USER";
var hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";

//设置网页打印的页眉页脚为空
function pagesetup_null()
{

    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,"");
}
//设置网页打印的页眉页脚为默认值s
function pagesetup_default()
{
try{
    var RegWsh = new ActiveXObject("WScript.Shell")
    hkey_key="header"
    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P")
    hkey_key="footer"
    RegWsh.RegWrite(hkey_root+hkey_path+hkey_key,"&u&b&d")
}catch(e){}
}
   
<!--此函数是为了解决全屏打印另外的一个打印函数-->
<!--printFunction()-->

function doPrint(oper) {
   if (oper < 10){
pagesetup_null();
bdhtml = window.document.body.innerHTML;//获取当前页的html代码
sprnstr = "<!--startprint"+oper+"-->";//设置打印开始区域
eprnstr = "<!--endprint"+oper+"-->";//设置打印结束区域
prnhtml = bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html

prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
window.document.body.innerHTML=prnhtml;

window.print();
pagesetup_default();
//window.document.all.wb.ExecWB(7,1);
//window.document.body.innerHTML=bdhtml;
} else{
pagesetup_null();
window.print();
pagesetup_default();
}

}

function preview(){
   var button=document.all.button
   button.style.display="none";
   var wb = document.all.wb;
       wb.ExecWB(7,1);
       button.style.display="block";
      
  
}

function dtPrint(){
if(window.print){
pagesetup_null();  
var print=document.all.print.innerHTML;
//var wb=document.all.wb;
//wb.ExecWB(7,1);
//var button=print.all.button;
// button.style.display="none";
document.body.innerHTML=print;  
window.print();
// document.all.button.display="block";
   pagesetup_default();
}
}



function issuanceClick()
{
   document.forms[0].method.value="submitMeetingRoomApp";
  
   validateMeetingRoomDisInfoShForm(document.forms[0]);
   document.forms[0].submit();
}
function backClick()
{
     document.forms[0].method.value="queryCarServiceInfo";
     return true;
}
function approveClick()
{
  
   document.forms[0].method.value="approveCarApp";
   return validatecarAppForm(document.forms[0]);
  
  
}
function returnClick()
{
   document.forms[0].method.value="returnCarApp";
   return validatecarAppForm(document.forms[0])
}
function saveClick()
{
  
   document.forms[0].method.value="saveCarAppOpinion";
   return validatecarAppForm(document.forms[0]);
  
  
}
</script>
</head>

 


<body>

<!--------------以下Table为路径-------->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
   <tr>
    <td height="30" class="place">
     <img src="<fmt:message key='CommonImagePath' />place_btn.gif"
      width="12" height="11">
     当前位置:北京市药监局 >> 辅助办公 >> 后勤管理 >> 处理用车申请
    </td>
   </tr>
   <tr>
    <td height="10" class="info">
     <c:if test="${requestScope.sign != null}">
      <br>
     &nbsp;&nbsp;&nbsp;    提示信息:<c:out value="${requestScope.sign}" />

     </c:if>
    </td>
   </tr>
</table>
<!--------------Table为路径结束-------->


<table width="95%" border="0" align="center" cellpadding="0"
   cellspacing="0" class="table1_border">
   <tr>
    <td class="table1_head_title">
     <img src="<fmt:message key='CommonImagePath' />table1_head_ico.gif"
      width="26" height="23" align="absmiddle">
     处理用车申请
    </td>
   </tr>
   <tr>
    <td height="10">

    </td>
   </tr>
   <tr>
    <td align="center">
     <html:javascript formName="carAppForm" />
     <html:errors />
     <html:form action="/draftCarApp" method="POST">
      <html:hidden property="method" value="saveCarServiceInfo" />
      <html:hidden property="csId" />
      <html:hidden property="ciId" />
      <html:hidden property="licensePlateNum" />
      <html:hidden property="appPerson" />
      <html:hidden property="nonceState" />
      <html:hidden property="masterSign" />
      <html:hidden property="useCarRequire" />
      <html:hidden property="masterSign" />
      <html:hidden property="piId" />
      <html:hidden property="useCarDate_web" />

      <br />

      <!--startprint1-->
      <div id=print>
       <OBJECT id="wb" height='0' width='0'
        classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>

       <table align="center" width="90%" border="0" align="center"
        cellpadding="0" cellspacing="1" class="table2_border">
        <tr>
         <td width="30%" class="table2_td_title">
          申请人:
         </td>
         <td class="table2_td">
          <html:hidden property="appPerId" />
          <html:hidden property="appPerson" />
          <c:out value="${carAppForm.appPerson}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          申请人所在部门:
         </td>
         <td class="table2_td">
          <html:hidden property="useCarDeptId" />
          <html:hidden property="useCarDept" />
          <c:out value="${carAppForm.useCarDept}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          用车原因:
         </td>
         <td class="table2_td">
          <html:hidden property="useCarCause" />
          <c:out value="${carAppForm.useCarCause}" />
         </td>
        </tr>

        <tr>
         <td width="30%" class="table2_td_title">
          用车要求:
         </td>
         <td class="table2_td">
          <html:hidden property="useCarRequire" />
          <c:forEach items="${worktypeList}" var="ParameterModel">
           <c:if
            test="${carAppForm.useCarRequire == ParameterModel.parameterID}">
            <c:out value="${ParameterModel.parameterValue}" />
           </c:if>
          </c:forEach>
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          人数:
         </td>
         <td class="table2_td">
          <html:hidden property="perAmount" />
          <!-- <img width="16" height="16" name="tan1" border="0" src="<fmt:message key='CommonImagePath' />tan.gif" onClick="getTime('leaveDate',1);" alt="">-->
          <c:out value="${carAppForm.perAmount}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          出发地点:
         </td>
         <td class="table2_td">
          <html:hidden property="leavePlace" />
          <!-- <img width="16" height="16" name="tan1" border="0" src="<fmt:message key='CommonImagePath' />tan.gif" onClick="getTime('leaveDate',1);" alt="">-->
          <c:out value="${carAppForm.leavePlace}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          到达地点:
         </td>
         <td class="table2_td">
          <html:hidden property="destination" />
          <!-- <img width="16" height="16" name="tan1" border="0" src="<fmt:message key='CommonImagePath' />tan.gif" onClick="getTime('leaveDate',1);" alt="">-->
          <c:out value="${carAppForm.destination}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          出车时间:
         </td>
         <td class="table2_td">
          <html:hidden property="leaveDate" />
          <!-- <img width="16" height="16" name="tan1" border="0" src="<fmt:message key='CommonImagePath' />tan.gif" onClick="getTime('leaveDate',1);" alt="">-->
          <c:out value="${carAppForm.leaveDate}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          收车时间:
         </td>
         <td class="table2_td">
          <html:hidden property="arriveDate" />
          <!-- <img width="16" height="16" name="tan1" border="0" src="<fmt:message key='CommonImagePath' />tan.gif" onClick="getTime('arriveDate',1);" alt="">-->
          <c:out value="${carAppForm.arriveDate}" />
         </td>
        </tr>

        <tr>
         <td class="table2_td_title">
          备&nbsp;&nbsp;&nbsp;&nbsp;注:
         </td>
         <td class="table2_td">
          <html:hidden property="remark" />
          <c:out value="${carAppForm.remark}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          车牌号:
         </td>
         <td class="table2_td">
          <html:hidden property="licensePlateNum" />
          <c:out value="${carAppForm.licensePlateNum}" />
         </td>
        </tr>
        <tr>
         <td width="30%" class="table2_td_title">
          司机姓名:
         </td>
         <td class="table2_td">
          <html:hidden property="motormanId" />
          <html:hidden property="motormanName" />
          <c:out value="${carAppForm.motormanName}" />
         </td>
        </tr>

        <!--endprint1-->
        <tr class="">
         <td align="center" colspan="2" class="table2_btn">
          <a href="#"><img alt="单击此按钮 打印页面" border=0
            name="imageField33"
            src="<fmt:message key='CommonImagePath' />btnPrint.gif"
            border="0" onclick="doPrint(1)" class="buttonImg"> </a>
          &nbsp;
          <input type="image" alt="单击此按钮 返回到列表页面"
           src="<fmt:message key='CommonImagePath' />btnBack.gif"
           onclick="return backClick()">


         </td>
        </tr>
       
       </table>
      </div>
     
      <table width="90%" border="0" align="center" cellpadding="0"
       cellspacing="0" class="table3_border">
       <tr>
        <td class="table3_title">
         意见列表
        </td>
       </tr>
      </table>

      <table width="90%" border="0" align="center" cellpadding="0"
       cellspacing="0" class="table3_border">
       <tr>
        <td>

         <display:table name="opinionList" class="dpTable"
          style="width:100%" id="displayTable">

          <display:column property="stepName" title="步骤"
           style="width:20%;text-align:center" />
          <display:column property="name" title="处理人"
           style="width:20%;text-align:center" />
          <display:column title="处理时间"
           style="width:20%;text-align:center">
           <fmt:formatDate value="${displayTable.writeDate}"
            pattern="yyyy-MM-dd HH:mm" />
          </display:column>
          <display:column property="opinion" title="意见"
           style="width:40%;text-align:center" />

         </display:table>
         <!-- 用Diaplay Tag来显示 -->
        </td>
       </tr>
      </table>
      <!-- 维护视图状态的隐藏域 -->
      <%@include file="../common/getDisplayParams1.jsp"%>
      <c:if test="${!empty param.nonceState_q}">
       <input type="hidden" name="nonceState_q"
        value="<c:out value="${param.nonceState_q}"/>">
      </c:if>
      <c:if test="${!empty param.useCarStartDate}">
       <input type="hidden" name="useCarStartDate"
        value="<c:out value="${param.useCarStartDate}"/>">
      </c:if>
      <c:if test="${!empty param.useCarEndDate}">
       <input type="hidden" name="useCarEndDate"
        value="<c:out value="${param.useCarEndDate}"/>">
      </c:if>
      <c:if test="${!empty param.useCarCause_q}">
       <input type="hidden" name="useCarCause_q"
        value="<c:out value="${param.useCarCause_q}"/>">
      </c:if>
      <!-- 维护视图状态的隐藏域 -->

     </html:form>

    </td>
   </tr>
</table>

 

</body>

</html:html>

posted on 2011-07-25 10:44 Mon$ter! 阅读(1777) 评论(0)  编辑  收藏

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


网站导航:
 
<2011年7月>
262728293012
3456789
10111213141516
17181920212223
24252627282930
31123456

常用链接

留言簿

随笔档案(11)

文章分类

最新随笔

搜索

  •  

最新评论

阅读排行榜

评论排行榜