How do i detect what browser does the client using?
i saw there is a $.browser in Jquery API Documention but its not longer works in jQuery 1.9.1.
any suggestions?
How do i detect what browser does the client using?
i saw there is a $.browser in Jquery API Documention but its not longer works in jQuery 1.9.1.
any suggestions?
I will suggest you to use feature detection instead of browser detection. Here is some detail about feature detection:
http://api.jquery.com/jQuery.support/
But for answer to your question, you can use this code to detect browser:
<script type="text/javascript">
$(document).ready(function() {
if (!navigator.userAgent.match(/mozilla/i) &&
! navigator.userAgent.match(/webkit/i) ){
alert('Mozilla');
}
});
</script>
You can use the jQuery Migrate plugin and call the $.browser
. It will work!
Using the plugin is easy; just include it immediately after the script tag for jQuery, for example.
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.1.1.js"></script>
JS:
$.each($.browser, function(i, val) {
$("<div>" + i + " : <span>" + val + "</span>")
.appendTo( document.body );
});
DEMO HERE (See Migrate 1.1.0 check box is checked on left side)
$.browser has been removed in 1.9 as it's was suggested feature detection was preferred via $.support
See this http://jquery.com/upgrade-guide/1.9/#jquery-browser-removed
Use jQuery Migrate plugin as William suggested