function IsPC(){
var userAgentInfo = navigator.userAgent;
var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
var flag = true;
for (var v = 0 ; v < Agents.length ; v++) {
if (userAgentInfo.indexOf(Agents[v]) > 0) {
flag = false; break;
}
}
return flag;
}
if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
alert("当前仅支持网页端浏览");
window.location.href ="ios.html";
}
else if (/(Android)/i.test(navigator.userAgent)) {
alert("当前仅支持网页端浏览");
window.location.href ="android.html";
}
else {
// window.location.href ="index.html";
};
IsPC();
【JavaScript】正则判断用户访问使用的客户端
于 2023-05-24 01:05:56 首次发布