地址栏不显示参数,主要是在使用pdf.js预览时不在地址栏显示传递的参数

  1. 原理
    即构造一个表单来替代原本的get请求使用拼接参数的方式来传递参数
  2. 构造表单
  3.         /*comment:查看信息详情
    		 *param: @rowIndex 行索引号
    		 */
    		 function showDetailInfo(fileId){
                var url = "<%=request.getContextPath() %>/fileManage/generic/web/redirectViewer.jsp";
    	        //首先创建一个form表单  
    	        var tempForm = document.createElement("form");    
    	        tempForm.id="tempForm1";  
    	        //制定发送请求的方式为post  
    	        tempForm.method="post";   
    	        //此为window.open的url,通过表单的action来实现  
    	        tempForm.action=url;  
    	        //利用表单的target属性来绑定window.open的一些参数(如设置窗体属性的参数等)  
    	        tempForm.target="_blank";   
    	        //创建input标签,用来设置参数  
    	        var hideInput = document.createElement("input");    
    	        hideInput.type="hidden";    
    	        hideInput.name= "fileIds";  
    	        hideInput.value= fileId; 
    	        //将input表单放到form表单里  
    	        tempForm.appendChild(hideInput); 
    	        //将此form表单添加到页面主体body中  
    	        document.body.appendChild(tempForm); 
    	        //手动触发,提交表单  
    	        tempForm.submit();
    	        //从body中移除form表单  
    	        document.body.removeChild(tempForm);  
    	    }
    	    

    新建一个jsp页面来接受参数

  4. <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <%@page import="com.primeton.cap.AppUserManager"%>
    <meta http-equiv="x-ua-compatible" content="IE=8;" />
    <html>
    <head>
    <%@include file="/coframe/tools/skins/common.jsp" %>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>PDF预览</title>
    <style type="text/css">
    .dtHighLight{
    	background:#F0F8FF !important;
    }
    </style>
    </head>
    <body >
    	<div style="width:100%;height:100%">
    			<iframe id="mainframe"  frameborder="0" name="main" style="width:100%;height:100%;" border="0"></iframe>
    	</div>
    </body>
    <script type="text/javascript">
    	
    </script>
    </html>
    <script type="text/javascript">
    	nui.parse();
    	
    		$(function(){
    			var mainIframe=document.getElementById('mainframe');
    		
    			if(mainIframe){
    				mainIframe.src="<%=request.getContextPath() %>/fileManage/generic/web/viewer.html?file="+encodeURIComponent("<%=request.getContextPath() %>/com.htfinance.htcm.fileManage.previewFile.previewFileInfo.flow?fileIds=<%=request.getParameter("fileIds") %>");
    			}
    		});	
    		
    	
    	
    	
    	
    </script>

    使用这种方式的原因就是pdf.js是根据文件流来显示pdf的,我需要传递一个文件的id过去。为了在地址栏隐藏这个id,使用了以上方式。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值