/ Published in: JavaScript
// adding ie version class on html tag
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//IE VERSION CONTROL function getInternetExplorerVersion() { var rv = -1; // Return value assumes failure. if (navigator.appName == 'Microsoft Internet Explorer') { var ua = navigator.userAgent; var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})"); if (re.exec(ua) != null) rv = parseFloat(RegExp.$1); } return rv; } function checkVersion() { var msg = "Internet Explorer"; var ver = getInternetExplorerVersion(); if (ver > -1) { $("html").addClass("ie").addClass("ie" + ver); //add version Class /* if ( ver >= 10.0 ) msg = "NEW browser." else msg = "Old browser.";*/ } } checkVersion();