码迷,mamicode.com
首页 > 移动开发 > 详细

原生JavaScript判断是否移动设备

时间:2016-04-06 12:57:39      阅读:185      评论:0      收藏:0      [点我收藏+]

标签:

function isMobile(){
  if (typeof this._isMobile === ‘boolean‘){
    return this._isMobile;
  }
  var screenWidth = this.getScreenWidth();
  var fixViewPortsExperiment = rendererModel.runningExperiments.FixViewport || rendererModel.runningExperiments.fixviewport;
  var fixViewPortsExperimentRunning = fixViewPortsExperiment && (fixViewPortsExperiment.toLowerCase() === "new");
  if(!fixViewPortsExperiment){
    if(!this.isAppleMobileDevice()){
      screenWidth = screenWidth/window.devicePixelRatio;
    }
  }
  var isMobileScreenSize = screenWidth < 600;
  var isMobileUserAgent = false;
  this._isMobile = isMobileScreenSize && this.isTouchScreen();
  return this._isMobile;
}

 

原生JavaScript判断是否移动设备

标签:

原文地址:http://www.cnblogs.com/shaoing/p/5358621.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!