Détection de la version d'Internet Explorer


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



Copy this code and paste it in your HTML
  1. <script>
  2. function getInternetExplorerVersion()
  3. // Returns the version of Internet Explorer or a -1
  4. // (indicating the use of another browser).
  5. {
  6. var rv = -1; // Return value assumes failure.
  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. return rv;
  15. }
  16. function checkVersion()
  17. {
  18. var msg = "You're not using Internet Explorer.";
  19. var ver = getInternetExplorerVersion();
  20.  
  21. if ( ver > -1 )
  22. {
  23. if ( ver >= 6.1 )
  24. msg = "You're using a recent copy of Internet Explorer."
  25. else
  26. msg = "You should upgrade your copy of Internet Explorer.";
  27. }
  28. alert( msg );
  29. }
  30. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.