Browser Detection


SUBMITTED BY: Guest

DATE: Jan. 15, 2014, 9:50 p.m.

FORMAT: JavaScript

SIZE: 826 Bytes

HITS: 650

  1. // Browser detection
  2. // Internet Explorer
  3. var ie = document.all != null; //ie4 and above
  4. var ie5 = document.getElementById && document.all;
  5. var ie6 = document.getElementById && document.all&&(navigator.appVersion.indexOf("MSIE 6.")>=0);
  6. // Netscape
  7. var ns4 = document.layers != null;
  8. var ns6 = document.getElementById && !document.all;
  9. var ns = ns4 || ns6;
  10. // Firefox
  11. var ff = !document.layers && !document.all;
  12. // Opera
  13. var op = navigator.userAgent.indexOf("opera")>0;
  14. var op7 = op && operaVersion() <= 7;
  15. var op8 = op && operaVersion() >= 8;
  16. // Detects the Opera version
  17. function operaVersion() {
  18. agent = navigator.userAgent;
  19. idx = agent.indexOf("opera");
  20. if (idx>-1) {
  21. return parseInt(agent.subString(idx+6,idx+7));
  22. }
  23. }

comments powered by Disqus