๐ป Programming/Javascript
[Javascript / ์๋ฐ์คํฌ๋ฆฝํธ] ๊ฐ์ข #21 - Navigator ( ๋ธ๋ผ์ฐ์ ํ๋ณ/๊ตฌ๋ถํ๊ธฐ )
์น์ ํ๋ฆฌ์ผ์ด์ ์ ๊ฐ๋ฐํ ๋ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ ๊ฐ ๋ฌด์์ธ์ง๋ ์ ๋ง ์ค์ํ ์์์ด๋ค. ๋ง์ฝ ์ฌ๋ฌ๊ฐ์ง ๋ธ๋ผ์ฐ์ ์์ ๋ชจ๋ ์ ์์ ์ธ ํ๋ฉด์ ๋ณด์ฌ์ฃผ๋ ค๋ฉด ์ ๋ง ๋ง์ ๋ ธ๋ ฅ์ ํด์ผํ๋ค. ๋ธ๋ผ์ฐ์ ๋ง๋ค ํ๋ฉด์ ๋ณด์ฌ์ง๋ ๋ชจ์ต์ด ๋ค๋ฅผ๋๊ฐ ๋ง๊ธฐ ๋๋ฌธ์ด๋ค.
์ค๋์ ์ฌ์ฉ์์ ๋ธ๋ผ์ฐ์ ๊ฐ ๋ฌด์์ธ์ง๋ฅผ ๊ตฌ๋ถํ ์ ์๊ฒํด์ฃผ๋ Navigator ๊ฐ์ฒด์ ๋ํด์ ์์๋ณด๋๋ก ํ๊ฒ ๋ค.
Navigator ์์ฑ
๋ค๋น๊ฒ์ดํฐ ๊ฐ์ฒด์ ์์ฑ์ ์๋์ ๊ฐ๋ค.
| Property | Description |
|---|---|
| appCodeName | ๋ธ๋ผ์ฐ์ ๊ณ ์ ์ ์ฝ๋๋ช ์ ๋ํ ์์ฑ์ด๋ค. ๋ท์ค์ผ์ดํ๋ Netscape , ์ต์คํ๋ก๋ฌ๋ Microsoft Internet Explorer ๊ฐ์ ๊ฐ์ง๋ค. |
| appVersion | ๋ธ๋ผ์ฐ์ ๋ฒ์ , ์ธ์ด, ํธํ์ฑ ๋ฑ๋ฑ์ ์ ๋ณด๋ฅผ ๊ฐ๋ ์์ฑ์ด๋ค. |
| language | ๋ท์ค์ผ์ดํ์์๋ง ์ฌ์ฉ๋๋ ์์ฑ์ด๋ค. ์ธ์ด์ฝ๋๋ฅผ ๋๊ฐ์ ์ผ๋ฆญํฐ๋ก ๊ฐ๋๋ค. ko, en ์ฒ๋ผ ๋ง์ด๋ค. |
| mimTypes[] | ํด๋ผ์ด์ธํธ(๋ธ๋ผ์ฐ์ )๊ฐ ์ง์ํ๋ ๋ชจ๋ MIME ํ์
์ ๊ฐ๊ณ ์๋ ์์ฑ์ด๋ค.์ญ์ ๋ท์ค์ผ์ดํ ์ ์ฉ์ด๋ค. |
| platform[] | ๋ธ๋ผ์ฐ์ ์ ํ๋ซ์ข ์ ๋ณด๋ฅผ ๊ฐ๋ ์์ฑ์ด๋ค."Win32" for 32-bit Windows operating systems |
| plugins[] | ๋ธ๋ผ์ฐ์ ์ ์ค์น๋ ๋ชจ๋ ํ๋ฌ๊ทธ์ธ์ ์ ๋ณด๋ฅผ ๊ฐ๋ ์์ฑ์ด๋ค. ๋ท์ค์ผ์ดํ ์ ์ฉ์ด๋ค. |
| userAgent[] | ์ฝ๋๋ช
๊ณผ ๋ธ๋ผ์ฐ์ ์ ๋ฒ์ ์ ๊ฐ๋ ์์ฑ์ด๋ค. ์๋ฒ์์ ํด๋ผ์ด์ธํธ๋ฅผ ๊ตฌ๋ถ์ง๊ธฐ์ํด ์ฌ์ฉ๋๋ค. |
Navigator ๋ฉ์๋
๋ค์์ Navigator์ ํนํ๋ ๋ฉ์๋๋ค์ ๋๋ค.
| Method | Description |
|---|---|
| javaEnabled() | ์๋ฐ์คํฌ๋ฆฝํธ๊ฐ ํ์ฑํ๋ ํด๋ผ์ด์ธํธ์ธ์ง๋ฅผ ๋ฐํํฉ๋๋ค. ๋ธ๋ผ์ฐ์ ์์ ์๋ฐ์คํฌ๋ฆฝํธ ์คํ์ ๊ธ์งํ๋ค๋ฉด false๋ฅผ ๋ฐํํฉ๋๋ค. |
| plugings.refresh | ์ด ๋ฉ์๋๋ ์๋ก ์ค์น๋ ํ๋ฌ๊ทธ์ธ์ ์ฌ์ฉํ๋๋ก ์ค์ ํ๊ณ ๋ชจ๋ ํ๋ฌ๊ทธ์ธ ๋ชฉ๋ก์ ์ถ๊ฐํฉ๋๋ค. Netscape only. |
| preference(name,value) | ์๋ช ๋ ์คํฌ๋ฆฝํธ๊ฐ ๋ท์ค์ผ์ดํ์ ์์ฑ๊ฐ์ ๊ฐ์ ธ์ค๊ฑฐ๋ ์ธํ ํ ์ ์๋๋ก ํด์ฃผ๋ ๋ฉ์๋์ ๋๋ค. ๋๋ฒ์งธ ์ธ์๊ฐ ์์ผ๋ฉด getter์ ์ญํ ์ ํ๊ณ ๋๋ฒ์งธ ์ธ์๋ฅผ ๋ฃ์ด์ฃผ๋ฉด setter์ ๊ธฐ๋ฅ์ ํ๊ฒ๋ฉ๋๋ค. Netscape only. |
| taintEnabled() | ๋ฐ์ดํ tainting ์ ํ์ฑํ ์ฌ๋ถ๋ฅผ ์ฐธ, ๊ฑฐ์ง์ผ๋ก ๋ฐํํฉ๋๋ค. |
๋ธ๋ผ์ฐ์ ๊ตฌ๋ณํ๊ธฐ
์๋ ์์ค๋ฅผ ๋ธ๋ผ์ฐ์ ์ข ๋ฅ๋ณ๋ก ํ ์คํธํด๋ณด์ธ์.
<html>
<head>
<title>Browser Detection Example</title>
</head>
<body>
<script type="text/javascript">
<!--
var userAgent = navigator.userAgent;
var opera = (userAgent.indexOf('Opera') != -1);
var ie = (userAgent.indexOf('MSIE') != -1);
var gecko = (userAgent.indexOf('Gecko') != -1);
var netscape = (userAgent.indexOf('Mozilla') != -1);
var version = navigator.appVersion;
if (opera){
document.write("Opera based browser");
// Keep your opera specific URL here.
}else if (gecko){
document.write("Mozilla based browser");
// Keep your gecko specific URL here.
}else if (ie){
document.write("IE based browser");
// Keep your IE specific URL here.
}else if (netscape){
document.write("Netscape based browser");
// Keep your Netscape specific URL here.
}else{
document.write("Unknown browser");
}
// You can include version to along with any above condition.
document.write("<br /> Browser version info : " + version );
//-->
</script>
</body>
</html>
|
Reference : http://www.tutorialspoint.com/javascript/javascript_browsers_handling.htm