Skip to content

Instantly share code, notes, and snippets.

@wataru218
Created June 19, 2014 23:59
Show Gist options
  • Save wataru218/3fb0ce3fa4aa83ae937f to your computer and use it in GitHub Desktop.
Save wataru218/3fb0ce3fa4aa83ae937f to your computer and use it in GitHub Desktop.
jQueryのbrowserでIE11を対応する
$(function() {
if (!$.browser.msie) {
// IE11は認識されないため、下記の対応を行います。
var ua = navigator.userAgent.toLowerCase();
var rmsie = /(trident)(?:.*? rv:([\w.]+))/;
var match = ua.indexOf('compatible') < 0 && rmsie.exec(ua) || [];
if (match[1] === 'trident') {
$.browser['msie'] = true;
$.browser.version = match[2] || '0';
}
// Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko
console.log(navigator.userAgent);
// {mozilla: true, msie: true, version: "11.0"}
console.log($.browser);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment