Javascript - Obtain explorer version


/ Published in: JavaScript
Save to your folder(s)

Returns the version of Windows Internet Explorer or a -1 (indicating the use of another browser).


Copy this code and paste it in your HTML
  1. // Returns the version of Windows Internet Explorer or a -1
  2. // (indicating the use of another browser).
  3. function getInternetExplorerVersion()
  4. {
  5. var rv = -1; // Return value assumes failure.
  6.  
  7. if (navigator.appName == 'Microsoft Internet Explorer')
  8. {
  9. var ua = navigator.userAgent;
  10. var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  11. if (re.exec(ua) != null)
  12. rv = parseFloat( RegExp.$1 );
  13. }
  14.  
  15. return rv;
  16. }

URL: http://www.mkyong.com/javascript/how-to-detect-ie-version-using-javascript/

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.