1

I have a JQuery-Datepicker that (however) crashes my site when you are using IE6. So I want the site to prevent the loading of that particular javascript on IE6.

I know about this trick:

<!--[if IE 6]>
  <script type="text/javascript" src="datepicker.js"></script>
<![endif]-->

But I need it the other way around: To load the Script if the browser is NOT IE 6. This will not work, since Mozilla & Co. will see just a simple comment:

<!--[if !IE 6]>
  <script type="text/javascript" src="datepicker.js"></script>
<![endif]-->

So, what's the best solution for this problem? Any ideas?

Thanks in advance.

1 Answer 1

1
var loadLibrary = true;
<!--[if IE 6]>
  loadLibrary = false;
<![endif]-->

if(loadLibrary)
{
   var s = document.createElement("script");
   s.setAttribute("type", "text/javascript");
   s.setAttribute("src", "datepicker.js");
   document.getElementsByTagName("head")[0].appendChild(s);
}
Sign up to request clarification or add additional context in comments.

1 Comment

that looks like javascript. but i am not sure, if there is a way to load a external javascript-file within a javascript-function. Could you be a little bit more specific, how the "..." would do something equivalent to: <script type="text/javascript" src="datepicker.js"></script>

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.