WEB에 액세스하는 플랫폼이 컴퓨터인지 휴대전화인지 판단하기

1301 단어 Web
//판단 플랫폼 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','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");
    };

좋은 웹페이지 즐겨찾기