//判断平台
isPCByPlat = function () {
var platForm = navigator.platform.toLowerCase();
var isWin = (platForm == “win32”) || (platForm == “win64”) || (platForm == “windows”) || (platForm.indexOf(“win”) > -1);
if (isWin)
return “windows”;
var isMac = (platForm == “mac68k”) || (platForm == “macppc”) || (platForm == “macintosh”) || (platForm == “macintel”);
if (isMac)
return “mac”;
return false;
};
//判断UA
isPCByOSList = function (uaArg) {
var pcOS = [“AIX”, “Amiga”, “BeOS”, “DragonFly”, “FreeBSD”, “GNU”, “Haiku”, “HP-UX”, “IRIX”, “Joli”, “Java”, “Macintosh”, “Minix”, “MorphOS”, “NetBSD”, “OpenBSD”, “PClinuxOS”, “QNX x86pc”, “SunOS”, “Ubuntu”, “Mint”, “Red Hat”, “Slackware”, “SUSE”, “PCLinuxOS”, “Debian”, “Fedora”, “CentOS”, “Vine”, “Arch Linux”, “Gentoo”, “Kanotix”, “Mandriva”];
for (var i = 0; i < pcOS.length; i++) {
if (uaArg.indexOf(pcOS[i]) > -1) {
return true;
}
};
return false;
};
if (isPCByPlat() || isPCByOSList(navigator.userAgent)) {
console.log("PC");
} else {
console.log("Mobile");
};