IE和chrome中,windows.location.href的不同跳转路径的解决方式
来源:互联网 发布:上海交大网络学校 编辑:程序博客网 时间:2024/06/10 16:46
ie中跳转以当前路径开始跳转
chrome中跳转以根目录开始
通过判断var userAgent = navigator.userAgent; 寻找userAgent中的字符串,判断当前浏览器。
如果需要到达同样的地址,可以在URL中,添加'<%=basePath%>'+url,表明根目录跳转,使IE正常跳转。
比如:
location.href=url;
在chrome中跳转正常,在IE中404,且出现重复路径,可以修改为:
location.href='<%=basePath%>'+url;
这样,在chrome和ie中都可以正常跳转。
附录:navigator对象包含有关浏览器的信息。
阅读全文
0 0
- IE和chrome中,windows.location.href的不同跳转路径的解决方式
- js用 window.location.href跳转IE和chrome中路径url不一致问题
- 解决在chrome浏览器使用js的window.location.href跳转页面失败的问题
- Chrome中使用location.href 跳转问题
- IE浏览器执行 window.location.href 跳转失败的解决办法
- IE下 window.location.href 跳转失效的解决方法
- window.location.href 在IE不跳转的解决方法
- location和location.href跳转url的区别
- location和location.href跳转url的区别
- location和location.href跳转url的区别
- location和location.href跳转url的区别
- location和location.href跳转url的区别
- location.replace()和location.href=进行跳转的区别
- location.replace()和location.href=进行跳转的区别
- JS 中document.URL 和 windows.location.href 的区别
- JS 中document.URL 和 windows.location.href 的区别
- JSP中window.location.href"、"location.href"、"parent.location.href"、"top.location.href"和"target属性"的用法
- 解决IE6下的 window.location.href 不能跳转问题
- CDH Can't scan a pre-transactional edit log,Timed out waiting 120000ms ,JournalNode数据文件破坏集群恢复方法
- 网页页面实现自动刷新的3种代码
- javaweb开发环境搭建
- 核心网一些基本知识
- “Beginning Python”(三)“Template System”
- IE和chrome中,windows.location.href的不同跳转路径的解决方式
- win32 API创建菜单资源
- Linux系统配置
- 【数学基础】概率统计
- 快速排序及其优化
- vue+webpack环境搭建
- EventBus之进阶使用详解
- 安装nginx时,常常会因为缺少依赖组件
- Xshell连接虚拟机的Linux