Detecting Browser Version


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



Copy this code and paste it in your HTML
  1. isMac = (navigator.appVersion.indexOf(”Mac”)!=-1) ? true : false;
  2. NS4 = (document.layers) ? true : false;
  3. IEmac = ((document.all)&&(isMac)) ? true : false;
  4. IE4plus = (document.all) ? true : false;
  5. IE4 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 4.”)!=-1)) ? true : false;
  6. IE5 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 5.”)!=-1)) ? true : false;
  7. IE6 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 6.”)!=-1)) ? true : false;
  8. IE7 = ((document.all)&&(navigator.appVersion.indexOf(”MSIE 7.”)!=-1)) ? true : false;
  9. ver4 = (NS4 || IE4plus) ? true : false;
  10. NS6 = (!document.layers) && (navigator.userAgent.indexOf(’Netscape’)!=-1)?true:false;
  11.  
  12. /*
  13. * We can also use
  14. */
  15. #
  16. if (typeof document.body.style.maxHeight != "undefined") {
  17. #
  18. // IE 7, mozilla, safari, opera 9
  19. #
  20. } else {
  21. #
  22. // IE6, older browsers
  23. #
  24. }
  25.  
  26. //or
  27.  
  28. if (window.XMLHttpRequest) {
  29. // IE 7, mozilla, safari, opera 9
  30. } else {
  31. // IE6, older browsers
  32. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.