日期:2014-05-16  浏览次数:20310 次

100个直接可以拿来用的JavaScript实用功能代码片段(二)

31、原生JavaScript判断是否移动设备

复制代码
 1 function isMobile(){
 2     if (typeof this._isMobile === 'boolean'){
 3         return this._isMobile;
 4     }
 5     var screenWidth = this.getScreenWidth();
 6     var fixViewPortsExperiment = rendererModel.runningExperiments.FixViewport || rendererModel.runningExperiments.fixviewport;
 7     var fixViewPortsExperimentRunning = fixViewPortsExperiment && (fixViewPortsExperiment.toLowerCase() === "new");
 8     if(!fixViewPortsExperiment){
 9         if(!