WEB/JAVASCRIPT-CONCEPT
예제 10-10. navigator 객체로 브라우저의 정보 출력
너래쟁이
2017. 11. 3. 10:20
6. navigator 객체
navigator 객체는 현재 작동중인 브라우저에 대한 다양한 정보를 나타내는 객체로써 다음과 같이 접근 한다.
window.navigator 또는 navigator
navigator 객체의 프로퍼티와 메소드
(프로퍼티)
appCodeName // 브라우저의 코드 이름을 가진 문자열
appName // 브라우저 이름 문자열
appVersion // 브라우저의 플랫폼과 버전에 관한 문자열
platform // 운영체제 플랫폼의 이름
product // 브라우저 엔진의 이름
userAgent // 브라우저가 웹 서버로 데이터를 전송할 때, HTTP 헤더 속의 user-agent 필드에 저장하는 문자열로서 웹 서버가 클라이언트를 인식하기 위한 목적
vender // 브라우저 제작 회사의 이름 문자열
language // 브라우저 언어를 나타내는 문자열로서, 영어는 "en-US", "ko-KR"
onLine // 브라우저가 현재 온라인 작동중이면 true, 아니면 false
plugins // 브라우저에 설치된 플러그인(plugin 객체)에 대한 컬렉션
cookieEnabled // 브라우저에 쿠키를 사용할 수 있는 상태이면 true, 아니면 false
geolocation // 위치 정보를 제공하는 geolocation 객체에 대한 레퍼런스
(메소드)
javaEnabled() // 자바 애플릿이 실행 가능하면 true 리턴, 아니면 false 리턴
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>브라우저 정보 출력</title> <style> span { color : blue; } div { border-color : yellowgreen; border-style : solid; padding : 5px; } </style> <script> function printNavigator() { var text = "<span>appCodeName</span>: " + navigator.appCodeName + "<br>"; text += "<span>appName</span>: " + navigator.appName + "<br>"; text += "<span>appVersion</span>: " + navigator.appVersion + "<br>"; text += "<span>platform</span>: " + navigator.platform + "<br>"; text += "<span>product</span>: " + navigator.product + "<br>"; text += "<span>userAgent</span>: " + navigator.userAgent +"<br>"; text += "<span>vendor</span>: " + navigator.vendor +"<br>"; text += "<span>language</span>: " + navigator.language + "<br>"; text += "<span>onLine</span>: " + navigator.onLine + "<br>"; text += "<span>cookieEnabled</span>: " + navigator.cookieEnabled + "<br>"; text += "<span>javaEnabled()</span>:" + navigator.javaEnabled() + "<br>"; text += "<span>plugins.length</span>: " + navigator.plugins.length + "<br>"; for(j=0; j<navigator.plugins.length; j++) { text += "plugins" + j + " : <blockquote>"; text += navigator.plugins[j].name + "<br>"; text += "<i>" + navigator.plugins[j].description + "</i><br>"; text += navigator.plugins[j].filename + "</blockquote>"; } // div 태그에 출력 var div = document.getElementById("div"); div.innerHTML = text; } </script> </head> <body onload="printNavigator()"> <h3>브라우저에 관한 정보 출력</h3> 아래에 이 브라우저에 관한 여러 정보를 출력합니다. <hr> <p> <div id="div"></div> </body> </html> | cs |