url解析问题

下面这种解析url路径跳转在很多机上的ie11浏览器上测试都ok
但在有一台ie11浏览器上解析会有问题
比如这个地址http://www.abc.com/m/tt/132
在个别机上的ie浏览器下会成http://www.abc.com/m/tt/undefined/m/tt/132
好生奇怪为什么会解析成这样?

let pathname = window.location.pathname;
let href = window.location.origin;
if(/^\/m\//.test(pathname)){
    pathname = pathname.replace(/\/m/,'');
    window.location.href = href + pathname;
}
阅读 2.1k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题