var ua = window.navigator.userAgent;
if(ua.toLowerCase().indexOf('iphone') != -1|| ua.toLocaleLowerCase().indexOf('ipad') != -1) {
$('body').addClass('ios').addClass('mobile');
} else if(ua.toLowerCase().indexOf('android') != -1) {
$('body').addClass('android').addClass('mobile');
} else {
$('body').addClass('pc');
}
判断用户当前的设备
最新推荐文章于 2023-07-18 17:01:09 发布
本文介绍了一种使用JavaScript来检测用户设备类型的方法,并根据不同设备类型为HTML文档的body元素添加相应的CSS类。该方法可以区分iOS设备、Android设备和其他被视为桌面电脑的设备。
6236

被折叠的 条评论
为什么被折叠?



