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]-->
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.