Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include a remote JavaScript file conditionally?

Tags:

I have a HTML page.

In that, according to the browser, I need to include a separate JavaScript file.

How is it possible?

<script type="text/javascript"> if(navigator.appName == 'Microsoft Internet Explorer') { //here i need to include one.js } else { //here i need to include two.js }  </script> 
like image 568
Linto Avatar asked Nov 10 '11 19:11

Linto


1 Answers

And finally, if you're already using JQuery in your project and just left out the tag for it, you can use $.getScript

like image 61
Dave Avatar answered Sep 25 '22 18:09

Dave