Home >Web Front-end >JS Tutorial >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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 17:48:081205browse

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