Posted By

denisko-redisko on 02/02/12


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

o0110o


Browser detection (is bad, absolutely, but)


 / Published in: JavaScript
 

Browser detection is bad, absolutely. But sometimes you need to display the inscription "you are using Opera browser" (or Chrome, FF, MSIE, Safari), or display the icon. You also need not be deceived if the user sets in the properties of "Mask as " a different browser.

  1. var browser = (
  2. /*@cc_on!@*/ 0 ? 'msie' :
  3. window.chrome ? 'chrome' :
  4. window.opera ? 'opera' :
  5. window.MouseScrollEvent ? 'gecko' :
  6. window.WheelEvent ? 'safari' :
  7. 'unknown'
  8. );
  9.  
  10. alert(browser)

Report this snippet  

You need to login to post a comment.