js判断设备是andriod还是ios还是微信内?
第一种方式很直接,通过userAgent,正则匹配
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { //alert(navigator.userAgent); window.location.href ="iPhone.html"; } else if (/(Android)/i.test(navigator.userAgent)) { //alert(navigator.userAgent); window.location.href ="Android.html"; } else { window.location.href ="pc.html"; };第二种比较全面,可以获取内核 是否是手机端、是否是微信qq内访问
//判断访问终端 var browser={ versions:function(){ var u = navigator.userAgent, app = navigator.appVersion; return { trident: u.indexOf('Trident') > -1, //IE内核 ...
点击查看剩余70%
网友评论0