0

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?

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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]-->

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.