Java Script & DOM/Java Script

방문자의 브라우저 정보 탐색: Navigator 객체

본클라쓰 2010. 12. 16. 09:53

 

자바스크립트는 브라우저에서 작동한다. 때때로 서버는 브라우저의 정보를 필요로 할 때가 있는데 Navigator객체가 브라우저의 정보를 제공한다. Navigator 객체는 방문자의 브라우저의 이름, 버전 등등의 정보를 가지고 있는 객체이다.

 

 

Navigator 객체 사용 예)

document.write("Browser CodeName: " + navigator.appCodeName);

document.write("<br /><br />");

document.write("Browser Name: " + navigator.appName);

document.write("<br /><br />");

document.write("Browser Version: " + navigator.appVersion);

document.write("<br /><br />");

document.write("Cookies Enabled: " + navigator.cookieEnabled);

document.write("<br /><br />");

document.write("Platform: " + navigator.platform);

document.write("<br /><br />");

document.write("User-agent header: " + navigator.userAgent); 

 

출력 결과)

Browser CodeName: Mozilla

 

Browser Name: Microsoft Internet Explorer

 

Browser Version: 4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)

 

Cookies Enabled: true

 

Platform: Win32

 

User-agent header: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)