Home > Article > Web Front-end > How does Js determine whether the client is a PC or a handheld device? Simple analysis_javascript skills
In the process of work, many friends will often use js to determine whether the client is a PC or a handheld device. Today we will provide the following method
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 if (userAgentInfo.indexOf(Agents[v]) > 0) { flag = false; break; }
}
return flag;
}