Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I include a javascript if it's IE, and another javascript if everything else?

I want to include <script src="ie.js"> if the browser is IE.

Otherwise, include all.js for all other browsers.

How can I do this?

like image 433
TIMEX Avatar asked Apr 20 '26 01:04

TIMEX


1 Answers

You can do this using conditional comments. Example:

<!--[if IE]>
    <script src="ie.js">
<![endif]-->
<!--[if !IE]><!-->
    <script src="all.js"></script>
<!--<![endif]-->
like image 119
aroth Avatar answered Apr 22 '26 21:04

aroth