메인메뉴 바로가기

HOME으로 가기


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

페이지 정보

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

본문

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;

}

댓글목록

등록된 댓글이 없습니다.