이 문서는 아직 자원 봉사자들이 한국어로 번역하지 않았습니다. 함께 해서 번역을 마치도록 도와 주세요!
The Window.navigator
read-only property returns a reference to the Navigator
object, which can be queried for information about the application running the script.
Syntax
navigatorObject = window.navigator
Examples
Example #1: Browser detect and return a string
var sBrowser, sUsrAg = navigator.userAgent; if(sUsrAg.indexOf("Chrome") > -1) { sBrowser = "Google Chrome"; } else if (sUsrAg.indexOf("Safari") > -1) { sBrowser = "Apple Safari"; } else if (sUsrAg.indexOf("Opera") > -1) { sBrowser = "Opera"; } else if (sUsrAg.indexOf("Firefox") > -1) { sBrowser = "Mozilla Firefox"; } else if (sUsrAg.indexOf("MSIE") > -1) { sBrowser = "Microsoft Internet Explorer"; } alert("You are using: " + sBrowser);
Example #2: Browser detect and return an index
function getBrowserId () { var aKeys = ["MSIE", "Firefox", "Safari", "Chrome", "Opera"], sUsrAg = navigator.userAgent, nIdx = aKeys.length - 1; for (nIdx; nIdx > -1 && sUsrAg.indexOf(aKeys[nIdx]) === -1; nIdx--); return nIdx } console.log(getBrowserId());
Specification
- HTML5
The definition of 'window.navigator' in that specification. - HTML5.1
The definition of 'window.navigator' in that specification. - WHATWG HTML Living Standard
The definition of 'window.navigator' in that specification.
See also
문서 태그 및 공헌자
태그:
이 페이지의 공헌자:
fscholz,
teoli,
kscarfone,
utkarsh_shah,
Jeremie,
ethertank,
Sheppy,
fusionchess,
markg,
leods92,
jswisher,
ziyunfei,
myakura,
wbamberg,
Marcoos,
ebidel,
Nickolay,
Ms2ger,
Mgjbot,
Ptak82,
Blueray,
George3,
SylvainPasche,
RyanFlint,
BenoitL,
Dumky,
Dria,
JesseW
최종 변경:
teoli,