js判断页面在pc端打开还是移动端打开,分别跳转不同的index.html

window.addEventListener('load', function() {
      // true为手机,false为pc
      if (!!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
           //跳转到移动端
           window.location.href = window.location.href.concat('m/');
      } else if (!navigator.userAgent.match(/AppleWebKit.*Mobile.*/)) {
          //跳转至pc端
           window.location.href = window.location.href.concat('pc/');
      }
})

  

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2021-10-29
  • 2021-11-26
猜你喜欢
  • 2022-02-14
  • 2018-04-08
  • 2022-12-23
  • 2021-12-18
  • 2022-12-23
  • 2021-11-26
  • 2022-12-23
相关资源
相似解决方案