方法: function isMobile() { var mobile_flag = false; //根据userAgent判断是否是手机 if((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|WebOS|Symbian|Windows Phone|Phone)/i))) { mobile_flag = true; } //根据屏幕分辨率判断是否是手机 var screen_width = window.screen.width; var screen_height = window.screen.height; if(screen_width < 500 && screen_height < 800){ mobile_flag = true; } return mobile_flag; }
end.