Browser detect for IE versions


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



Copy this code and paste it in your HTML
  1.  
  2. function isIE(versionNumber) {
  3. var detect = navigator.userAgent.toLowerCase();
  4. if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase)) {
  5. return false;
  6. } else {
  7. if(detect.indexOf('msie') + 1) {
  8. // browser is internet explorer
  9. var ver = function() {
  10. // http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
  11. // Returns the version of Internet Explorer or a -1
  12. // (indicating the use of another browser).
  13. var rv = -1; // Return value assumes failure
  14. if (navigator.appName == 'Microsoft Internet Explorer') {
  15. var ua = navigator.userAgent;
  16. var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
  17. if (re.exec(ua) != null) {
  18. rv = parseFloat( RegExp.$1 );
  19. }
  20. }
  21. return rv;
  22. };
  23. var valid = true;
  24. // if the version can be found and the version is less than our version number it is invalid
  25. if ((ver > -1) && (ver < versionNumber)) {
  26. valid = false;
  27. }
  28. return valid;
  29. } else {
  30. return false
  31. }
  32. }
  33. }
  34.  
  35.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.