I\'ve been having some major issues with a layout I\'m making specifically in Internet Explorer. I know IE converts width and heights differently when there is borders and p
I would use this approach because, in my opinion, it's cleaner and more accurate then loading two scripts and overwriting code, like in accepted answer.
In this code iemenu.js will be loaded only if it is IE version less then IE9 and in other cases, like IE9-10-11 or any other browser, it will load menu.js
<!--[if lt IE 9]>
<script src="iemenu.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script src="menu.js"></script>
<!--<![endif]-->
Here is example and discussion about two different versions of jQuery: http://www.impressivewebs.com/loading-different-jquery-version-ie6-8/
Maybe I'm late with answer :) ...
Try to detect the misbehavior and use jQuery.support if possible since jQuery.browser is deprecated.
Your need $.browser
if ($.browser.msie) {
alert("this is ie!");
}
For script loading you can use $.getScript
$.getScript('ajax/test.js', function() {
alert('Load was performed.');
});
So the final example
<script type="text/javascript" src="iemenu.js">
if ($.browser.msie) {
$.getScript('iemenu.js', function() {});
}
</script>
Try it like this:
<script type="text/javascript">var runFancy = true;</script>
<script>runFancy = true;</script>
<script type="text/javascript" src="menu.js"></script>
<!--[if IE]>
<script type="text/javascript">
runFancy = false;
</script> // <script type="text/javascript" src="iemenu.js"></script>
<![endif]-->
In this case menu.js will be loaded first and iemenu.js will be loaded afterwards. And if the functions are the same, the iefunction will overwrite the "normal" function and it should work.
Your menu.js will load always, because it is not in any if. If it overwrites your functions, you'd be back to square one.
A sollution might be to load the menu first, but that's a bit of a hack. still