본문 바로가기

Javascript

[Javascript] Chrome, IE 브라우저 종류 확인 navigator userAgent

Javascript navigator로 브라우저 구분하기

 

IE 브라우저

 

var agent = navigator.userAgent.toLowerCase();

if( navigator.appName == 'Netscape' && navigator.userAgent.search('Trident') != -1 || (agent.indexOf("msie") != -1)) {
  console.log("Internet Explorer 브라우저입니다.");
}

 

 

Internet Explorer 11

mozilla/5.0 (windows nt 10.0; wow64; trident/7.0; .net4.0c; .net4.0e; .net clr 2.0.50727; .net clr 3.0.30729; .net clr 3.5.30729; infopath.3; rv:11.0) like gecko

 

 

Internet Explorer 10

mozilla/5.0 (compatible; msie 10.0; windows nt 10.0; wow64; trident/7.0; .net4.0c; .net4.0e; .net clr 2.0.50727; .net clr 3.0.30729; .net clr 3.5.30729; infopath.3)

 

 

Internet Explorer 9

mozilla/5.0 (compatible; msie 9.0; windows nt 10.0; wow64; trident/7.0; .net4.0c; .net4.0e; .net clr 2.0.50727; .net clr 3.0.30729; .net clr 3.5.30729; infopath.3)

 

 

 

Chrome 브라우저

 

var agent = navigator.userAgent.toLowerCase();

if( agent.indexOf("chrome") != -1) {
  console.log("Chrome 브라우저입니다.");
}

 

mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/88.0.4324.190 safari/537.36