Easiest/Lightest Replacement For Browser Detection jQuery 1.9?

jchwebdev picture jchwebdev · Jan 16, 2013 · Viewed 63.2k times · Source

I had several clients complain yesterday that some code stopped working. Apparently it comes down to plug-ins using the now deprecated jQuery.browser which stopped working yesterday when jQuery 1.9 was released.

I (quickly) looked at the 1.9 change docs and it seems like they want me to substitute some pretty heavy libraries just for that one function.

Is there a recommended lightest weight plug-in or code snippet to restore that functionality?

For what these sites need, it's very basic; I only need the most basic detection of IE vs FF vs everyone else.

Suggestions?

Answer

Fede picture Fede · Apr 24, 2013

I've use the following code answered by Alexx Roche, but i wanted to detect MSIE so:

<script type="text/javascript">
   $(document).ready(function() {
      if (navigator.userAgent.match(/msie/i) ){
        alert('I am an old fashioned Internet Explorer');
      }
   });
</script>

hope it helps!