본문 바로가기

소프트웨어

인터넷 익스플로러 IE javascript로 잡아내기

인터넷 익스플로러가 최신 jQuery를 지원하지 않는다. 따라서 기피해야하는데, 유저들을 잘 모르는 경우가 많기 때문에 익스플로러로 접속했을 경우 경고 알림을 띄워줄 때 사용하는 코드이다.

https://stackoverflow.com/questions/24861073/detect-if-any-kind-of-ie-msie
에서 가져왔고, IE 5-11을 아주 잘 잡아낸다.

if (navigator.appName == 'Microsoft Internet Explorer' ||  !!(navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/rv:11/)) || (typeof $.browser !== "undefined" && $.browser.msie == 1))
{
  alert("Please dont use IE.");
}