I\'m using an image carousel script that is quite heavy on the browser. It works great in Opera and Chrome, half decent in FF and absolutely breaks my balls in IE. So i\'d l
var browserName=navigator.appName; if (browserName=="Microsoft Internet Explorer") { document.write("Your html for IE") }
Try this: The systemLanguage and the userLanguage is undefined in all browser.
if(navigator.userLanguage !== "undefined" && navigator.systemLanguage !== "undefined" && navigator.userAgent.match(/trident/i)) {
alert("hello explorer i catch U :D")
}
You define a boolean value with default of true, and then inside an IE conditional comment, set the value to false, and use the value of this to determine whether your advanced code should run. Something like:
<script type="text/javascript">var runFancy = true;</script>
<!--[if IE]>
<script type="text/javascript">
runFancy = false;
//any other IE specific stuff here
</script>
<![endif]-->
<script type="text/javascript">
if (runFancy) {
//do your code that works with sane browsers
}
</script>
For IE10+ standard conditions don't work cause of engine change or some another reasons, cause, you know, it's MSIE. But for IE10+ you need to run something like this in your scripts:
if (navigator.userAgent.match(/Trident\/7\./)) {
// do stuff for IE.
}
You can do something like this to include IE-specific javascript:
<!--[IF IE]>
<script type="text/javascript">
// IE stuff
</script>
<![endif]-->
this code works well on my site because it detects whether its ie or not and activates the javascript if it is its below you can check it out live on ie or other browser Just a demo of the if ie javascript in action
<script type="text/javascript">
<!--[if IE]>
window.location.href = "http://yoursite.com/";
<![endif]-->
</script>