I’m trying to dynamically add a script if a user is using Internet explorer. I tried IE Conditionals but chrome didn’t like the !IE tag so I’m trying it the jquery way:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" ></script>
<script type="text/javascript">
if($.browser.msie){
document.write('<script type="text/javascript" src="ie/ieFix.js" ></script>');
}
else{
document.write('<script type="text/javascript" src="dynamic.js" ></script>');
}
</script>
I’m not sure why its not letting me just add this, instead it returns '); } else{ document.write(''); }
Throwing them in variables has the same effect :/
IE Conditionals
<!--[if !ie]>-->
<script type="text/javascript" src="dynamic.js" ></script>
<!--<![endif]-->
<!--[if ie]>-->
<script type="text/javascript" src="ie/ieFix.js" ></script>
<!--<![endif]-->
The
</script>in the lineactually matches as the end tag of
on the line above it. You should rewrite it to something like
so you don’t confuse the browser with the closing
</script>tag.