Use Navigator.userAgent.toLowerCase () to determine the type of mobile end
Judging equipment, distinguishing between android,iphone,ipad and other
var ua = Navigator.userAgent.toLowerCase (); if (Ua.match (/android/i)) = = "Android") { alert ("Android"); } if (Ua.match (/iphone/i)) = = "iphone") { alert ("iphone"); } if (Ua.match (/ipad/i)) = = "ipad") { alert ("ipad"); }
Determine whether a particular type of browser, such as Sina Weibo client built-in browser, QQ client built-in browser (not QQ browser), built-in browser
(and differentiate whether the version is greater than or equal to 6.0.2) (specific types of browsers may exist, cannot be downloaded, cannot jump and specific protocols of their own client app, etc.), so need to differentiate)
(Because of the new strategy in 6.0.2, the sharing function is different in the new version, in order to be compatible with the old and new version, there is a differentiated operation)
Sina Weibo client returns the 1,QQ client returns 2, less than 6.0.2 returns 3, greater than or equal to 6.0.2 version return 4, other return 0
var ua = Navigator.userAgent.toLowerCase (); if (Ua.match (/weibo/i) = = "Weibo") { return 1; } else if (ua.indexof (' qq/')! =-1) { return 2; } else if (ua.match (/micromessenger/i) = = "Micromessenger") { var v_weixin = ua.split (' Micromessenger ') [1]; V_weixin = v_weixin.substring (1,6); V_weixin = V_weixin.split (") [0]; if (V_weixin.split ('. '). length = = 2) { v_weixin = v_weixin + '. 0 '; } if (V_weixin < ' 6.0.2 ') { return 3; } else{ return 4; } } else{ return 0; }
Use Navigator.userAgent.toLowerCase () to determine the type of mobile end