Home  >  Article  >  Web Front-end  >  How does Js determine whether the client is a PC or a handheld device? Simple analysis_javascript skills

How does Js determine whether the client is a PC or a handheld device? Simple analysis_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:48:081175browse

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;
}

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn