Определить что браузер IE6 с помощью JS

Задача – определить, что браузерм является IE6

Обычный метод – parseFloat(navigator.appVersion) – не подходит, т.к возвращает  цифру 4 – номер версии движка, а она одинакова как для IE7 так и для IE6.

parseFloat(navigator.appVersion)  – возвращает 4.0 (compatible; MSIE 6.0; Windows NT 5.2; Win64; x64; SV1; .NET CLR 2.0.50727). Напишем фугкцию, которая будет парсить эту строку, т.е выбирать эту часть -MSIEс весрие настоящей.

function is_IE6(){
  var browser = navigator.appName;
  if (browser == "Microsoft Internet Explorer"){
    var b_version = navigator.appVersion;
    var re = /\MSIE\s+(\d\.\d\b)/;
    var res = b_version.match(re);
    if (res[1] <= 6){
      return true;
    }
  }
  return false;
}
This entry was posted in JavaScript. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>