在使用window.location时,我们会发现IE和Firefox/Chrome的跳转不一致,采用以下代码可以解决:

function History(id, typeText) {
    var browser = navigator.userAgent;
    if (browser.indexOf("Chrome") != -1 || browser.indexOf("Firefox") != -1) {
    	window.location = "PriceOverTime/Index/History";
    } else {
    	window.location = "Index/History";
    }
}

如上代码,IE是基于当前页面的路径来进行跳转,而Firefox/Chrome是基于base=ContextPath跳转。

<%   
String path = request.getContextPath();   
String basePath = request.getScheme()+"://" +request.getServerName()+":" +request.getServerPort()+path+"/" ;   
%>   
<base href="<%=basePath%>" >

注意,我的页面首部使用了base标签来设置固定的base=ContextPath。

发表评论

邮箱地址不会被公开。 必填项已用*标注