isMobile.js 654 B

123456789101112131415161718192021222324252627
  1. ;(function () {
  2. console.log('进来了')
  3. // 判断移动端
  4. var sUserAgent = navigator.userAgent.toLowerCase()
  5. if (
  6. /ipad|iphone|midp|rv:1.2.3.4|ucweb|android|windows ce|windows mobile/.test(
  7. sUserAgent
  8. )
  9. ) {
  10. //跳转移动端页面
  11. if (window.location.href.indexOf('mobile') < 0) {
  12. window.location.replace('/m_user') //跳转后没有后退功能
  13. }
  14. } else {
  15. // PC端
  16. console.log('pc')
  17. }
  18. })()
  19. (function(window){
  20. window.onresize=function(){
  21. rem();
  22. }
  23. function rem(){
  24. document.documentElement.style.fontSize = document.documentElement.clientWidth /7.2 + "px";
  25. }
  26. rem();
  27. })(window);