IE8预览下载word时一闪而过,IE6没问题

解决办法:

跳转页面前的javascript:

		  //预览附件
	    function preView() {
	  	  	var keywordId=${keyword.id}+"";
	    	$.post("${URL}/event/event!preView.action",
	    			{kwid:keywordId},
	    			function(data, status){
	    				if(data == "noexists") {
	    					alert("附件不存在,请先生成附件!");
	    					return;
	    				} else {
	    					//window.open('${URL}/yq/yqPublication!preView.action?indexno='+indexno, 'newwindow', 'toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no');
	    					//window.open('${URL}' + data, 'preViewWindow', 'toolbar=no, menubar=no, scrollbars=no, resizable=yes, location=no, status=no');
	    					//location.href='${URL}' + data;
	    					var isIE=!!window.ActiveXObject;
	    					var isIE6=isIE && !window.XMLHttpRequest;
	    					var isIE8=isIE && !!document.documentMode;
	    					var isIE7=isIE && !isIE6 && !isIE8;
	    					if (isIE){
	    						if (isIE6){
	    							window.open('${URL}' + data);
	    							//alert("ie6");
	    						}else if (isIE8){
	    							window.open('event!download.action?url=' + '${URL}' + data);
		    						//alert("ie8");
		    					}else if (isIE7){
		    						window.open('event!download.action?url=' + '${URL}' + data);
		    						//alert("ie7");
		    					} else {
		    						window.open('${URL}' + data);
			    					//alert("其他浏览器暂时不支持");
		    					}
	    					}
	    					
	    				}
	    			}
	    		);
	    }

Action里面处理:

	public String download() throws Exception {
		try {
			String url = Struts2Utils.getRequest().getParameter("url");
			if(Validator.isNotNull(url)) {
				Struts2Utils.getRequest().setAttribute("url", url);
			}
			//Struts2Utils.getResponse().getWriter().write("<script>location.href='event!download.action?url=" + url + "';</script>");
			//Struts2Utils.getResponse().sendRedirect(url);
		} catch (Exception e) {
			logger.error("预览下载简报出错", e);
		}
		return "download";
	}

返回后的页面:

<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<html>
	<head>
	</head>
	<body>
	</body>

<script type="text/javascript">
locationTo();


function locationTo() {
	var urlString = location.href;
	if(urlString == "" || urlString == null) {
		alert("附件不存在,请重新生成!");
		return;
	}
	                                      	
	var url = urlString.split("url=")[1];
	window.location=url;
}

</script>
</html>


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值