IE和chrome中,windows.location.href的不同跳转路径的解决方式
2017-07-03 14:56
465 查看
ie中跳转以当前路径开始跳转
chrome中跳转以根目录开始
通过判断var userAgent = navigator.userAgent; 寻找userAgent中的字符串,判断当前浏览器。
如果需要到达同样的地址,可以在URL中,添加'<%=basePath%>'+url,表明根目录跳转,使IE正常跳转。
比如:
location.href=url;
在chrome中跳转正常,在IE中404,且出现重复路径,可以修改为:
location.href='<%=basePath%>'+url;
这样,在chrome和ie中都可以正常跳转。
附录:navigator对象包含有关浏览器的信息。
chrome中跳转以根目录开始
通过判断var userAgent = navigator.userAgent; 寻找userAgent中的字符串,判断当前浏览器。
如果需要到达同样的地址,可以在URL中,添加'<%=basePath%>'+url,表明根目录跳转,使IE正常跳转。
比如:
location.href=url;
在chrome中跳转正常,在IE中404,且出现重复路径,可以修改为:
location.href='<%=basePath%>'+url;
这样,在chrome和ie中都可以正常跳转。
附录:navigator对象包含有关浏览器的信息。
相关文章推荐
- js用 window.location.href跳转IE和chrome中路径url不一致问题
- location.href方式跳转传值中文乱码解决
- 使用window.location.href跳转页面在IE和FF浏览器中路径不一致的问题总结
- 解决在有base href 时location ie/ff处理不同问题方法
- IE下 window.location.href 跳转失效的解决方法
- window.location.href 在IE不跳转的解决方法
- ie下对于window.location.href的跳转时获取不到referer的,php中的路径包含有未定式的
- location.href方式跳转传值中文乱码解决
- window.location.href 在傲游兼容模式和IE下不跳转的解决办法(同事分享的)
- location.href在IE中不会跳转到指定的页面
- Goahead 在Chrome跳转top.location.href 导致卡死问题
- location.href不跳转的解决办法
- IE6 中 window.location.href 不能跳转 以及关于a标签点击返回顶部的解决方法
- windows8.1 打不开网页 除ie外打不开网页 firefox chrome 打不开网页解决方法
- 解决AD域下用运行方式安装出现“windows 无法访问指定设备、路径或文件。”
- Android中不同包路径下Activity跳转的实现(解决ActivityNotFoundException)
- Android中不同包路径下Activity跳转的实现(解决ActivityNotFoundException)
- IE浏览器执行 window.location.href 跳转失败的解决办法