美文网首页
判断PC端和移动端

判断PC端和移动端

作者: 宏_4491 | 来源:发表于2020-08-26 09:02 被阅读0次

做企业官网的项目会遇到判断设备是移动端还是pc端

  <meta http-equiv="mobile-agent" content="format=xhtml;url=./m/index.html">
  <script
    type="text/javascript">if (window.location.toString().indexOf('pref=padindex') != -1) { } else { if (/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))) { if (window.location.href.indexOf("?mobile") < 0) { try { if (/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) { window.location.href = "./m/index.html"; } else if (/iPad/i.test(navigator.userAgent)) { } else { } } catch (e) { } } } }</script>

相关文章

网友评论

      本文标题:判断PC端和移动端

      本文链接:https://www.haomeiwen.com/subject/wsqxsktx.html