当前位置 : 主页 > 网络编程 > JavaScript >

webpage-skipping

来源:互联网 收集:自由互联 发布时间:2021-06-30
webpage skip between PC to moblie ;(function () { var isMobile = false // 默认PC端 function mobile() { try { document.createEvent("TouchEvent") return true } catch (e) { return false } } isMobile = mobile() var str = window.location.href
webpage skip between PC to moblie
;(function () {
  var isMobile = false // 默认PC端
  function mobile() {
    try {
      document.createEvent("TouchEvent")
      return true
    }
    catch (e) {
      return false
    }
  }

  isMobile = mobile()
  var str = window.location.href
  if (isMobile && str.indexOf('https://m.') === -1) {
    //移动端的处理逻辑
    str = str.replace('https://', 'https://m.')
    window.location.href = str
  } 
  if (!isMobile && str.indexOf('https://m.') !== -1) {
    //PC端的处理逻辑
    str = str.replace('https://m.', 'https://')
    window.location.href = str
  }
})()
上一篇:history ajax
下一篇:Angular_Ui_Router.Txt
网友评论