I need to detect the browser with JavaScript.
I have an image gallery with different js files for FireFox, Chrome, and IE. How can I detect the browser display the corresponding file?
If you are already using jquery you can use their API to detect the browser. Otherwise you can extract the users browser from the navigator.useragent property.
You could also use conditional comments in the HTML to grab entirely different script files:
<!--[if IE]>
<script src="http://example.com/ie-specific.js"></script>
<![endif]-->
<!--[if !IE]> -->
<script src="http://example.com/real-browsers.js"></script>
<!-- <![endif]-->