자바스크립트로 OS 체크 > Javascript

본문 바로가기

사이트 내 전체검색

뒤로가기 Javascript

사용자함수 자바스크립트로 OS 체크

페이지 정보

작성자 너갱이 작성일 18-11-18 17:14 조회 2,054 댓글 0

본문

detect : { //OS 체크

regexCheck : function (regexString) {

return (regexString).test(navigator.userAgent);

},

isWindows : function () {

return this.regexCheck(/(windows\sphone(?:\sos)*|windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i);

},

isWinRT : function () {

return this.regexCheck(/(windows)\snt\s6\.2;\s(arm)/i);

},

isWin10 : function () {

return this.regexCheck(/(edge)\/((\d+)?[\w\.]+)/i);

},

isiOS : function () {

return this.regexCheck(/(ip[honead]+)(?:.*os\s([\w]+)*\slike\smac|;\sopera)/i);

},

isMac : function () {

return this.regexCheck(/(macintosh|mac(?=_powerpc)\s)/i);

},

isAndroid : function () {

return this.regexCheck(/(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|contiki)[\/\s-]?([\w\.]+)*/i);

},

isLinux : function () {

return this.regexCheck(/(joli|[kxln]?ubuntu|debian|[open]*suse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?([\w\.-]+)*/i);

},

getPlatform : function () {

var platform;

if (this.isWindows()) {

platform = 'WIN';

}

if (this.isWin10()) {

platform = 'RT';

}

if (this.isiOS()) {

platform = 'IOS';

}

if (this.isMac()) {

platform = 'MAC';

}

if (this.isAndroid()) {

platform = 'ANDROID';

}

if (this.isLinux()) {

platform = 'LINUX';

}

return platform;

}

댓글목록 0

등록된 댓글이 없습니다.

Copyright © 소유하신 도메인. All rights reserved.

사이트 정보

회사명 : 회사명 / 대표 : 대표자명
주소 : OO도 OO시 OO구 OO동 123-45
사업자 등록번호 : 123-45-67890
전화 : 02-123-4567 팩스 : 02-123-4568
통신판매업신고번호 : 제 OO구 - 123호
개인정보관리책임자 : 정보책임자명

PC 버전으로 보기