js判断设备信息,安卓、ios、还是pc端

时间:2023-03-09 05:40:39
js判断设备信息,安卓、ios、还是pc端
前端开发获取设备信息的代码
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
window.location.href ="https://itunes.apple.com/cn/app/1hao-yao-dian/id727578007?mt=8";
} else if (/(Android)/i.test(navigator.userAgent)) {
window.location.href ="https://itunes.apple.com/cn/app/1hao-yao-dian/id727578007?mt=8";
} else {
window.location.href ="http://www.111.com.cn/";
};