Jquery Browser Detection Example - Jquery

How to detect browser name using jquery

Snippet Code


  
Rate this page :
  [ 0 votes]

Different type of browsers are identified through this simple jquery code. The code detect_browser() is used to find out the different browsers name.

<script type='text/javascript'> function detect_browser() { $.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase()); var browsername; if($.browser.chrome){ $.browser.safari = false; browsername = "Chrome"; } if($.browser.safari){ browsername = "Safari"; } if ($.browser.mozilla){ browsername = "Mozilla"; } if( $.browser.opera){ browsername = "Opera"; } if ($.browser.msie){ browsername = "IE"; } return browsername; } $(document).ready(function(){ var browser = detect_browser(); alert(browser); }) </script>

Tags


Ask Questions

Ask Question