[JS] navigator 객체 (navigator.appName, navigator.appCodeName, navigator.appVersion, navigator.userAgent)
2021. 8. 2. 21:23
728x90
01 현재 브라우저의 이름 // navigator.appName, navigator.appCodeName
- 브라우저 간의 호환성을 위해 스니핑 코드로 대부분의 브라우저가 브라우저 이름을 Netscape로 사용.
- 또한, 대부분의 브라우저가 브러우저 코드명을 Mozilla로 사용.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>navigator</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script>
// 해당 브라우저 이름
document.write(navigator.appName, "<br>");
// 해당 브라우저 코드 이름
document.write(navigator.appCodeName);
</script>
</head>
<body>
</body>
</html>
02 현재 브라우저의 버전 // navigator.appVersion, navigator.userAgent
- 현재 사용하고 있는 브라우저의 버전 정보를 문자열로 반환.
- userAgent 프로퍼티의 결과값은 appVersion 프로퍼티의 정보뿐만 아니라 상세 정보를 추가로 포함.
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>navigator</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<script>
// 해당 브라우저의 버전
document.write(navigator.appVersion, "<br>");
// userAgent 프로퍼티로 알 수 있는 추가 정보
document.write(navigator.userAgent);
</script>
</head>
<body>
</body>
</html>
03 그외
프로퍼티 | 설명 |
navigator.platform | 현재 브라우저가 실행되고 있는 운영체제를 식별하는 문자열을 반환 |
navigator.language | 현재 사용 중인 브라우저의 기본 언어 설정을 반환 |
navigator.deviceMemory | 장치의 메모리를 기가바이트 단위로 반환 |
728x90
'JavaScript > Study' 카테고리의 다른 글
[JS] DOM 요소의 선택 (0) | 2021.08.02 |
---|---|
[JS] 함수 (function, 함수선언문, 함수표현식, 반환문, 재귀 함수) (0) | 2021.08.02 |
[JS] location 객체 (location.href, location.reload) (0) | 2021.08.02 |
[JS] History 객체 (histroy.forward, histroy.back) (0) | 2021.07.30 |
[JS] 대화상자 (alert, confirm) (0) | 2021.07.30 |