Jquery Detect Browser - Jquery

How can i detect browser type using jquery code?

Snippet Code

Rate this page :
  [ 0 votes]

The following jquery code can be used to detect browser type. Here, $.browser property gives information about the web browser that is accessing the page.

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


Ask Questions

Ask Question