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

WBOY
Release: 2016-05-16 17:48:08
Original
1182 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template