사용자함수 자바스크립트로 OS 체크
페이지 정보

본문
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;
}
}
- 이전글JSON.stringify(); //JSON Object를 문자열로 변환. 18.11.19
- 다음글자바스크립트를 사용하여 CSS 바꾸기 18.11.18
댓글목록
등록된 댓글이 없습니다.

