We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

arunpjohny on 09/09/07


Tagged

javascript


Versions (?)


Who likes this?

2 people have marked this snippet as a favorite

markupmark
vali29


Detecting Browser Version


Published in: JavaScript 


  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 

You need to login to post a comment.