9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

<!--[if lt IE 9 ]> <![endif]-->をJavaScriptでやりたい

Posted at

参考:http://stackoverflow.com/questions/17907445/how-to-detect-ie11

// IEだった場合はバージョン番号を返す。それ以外ではNaNを返す。
function ieVer(){
  var msie = parseInt((/msie (\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);

  if (isNaN(msie)) {
    msie = parseInt((/trident\/.*; rv:(\d+)/.exec(navigator.userAgent.toLowerCase()) || [])[1]);
  }
  return msie;
}

// IEかどうかの判定
var isIE = !isNaN(ieVer());

// IEのバージョンを取得
var version = ieVer();

// IE9未満かどうか
var ver = ieVer();
if (!isNaN(ver) && ver < 9) {
  // IE9未満の場合のみ
}
9
9
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
9

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?