Orientation IE 8 and below?

I have a script that works fine in IE 9+ and in all other browsers. But in IE 8 or lower there are visual errors. I can fix these visual errors by changing some animation effects for IE 8 and below. For this, I need to have two scripts on my page. One for IE 9+, Firefox, Chrome, Safari, and another for IE 8 and below.

Here is what I tried:

// First the Script that runs for non-IE browsers. 
<!--[if !IE]>
<script type="text/javascript">
// Script that runs
</script>
<![endif]-->

// Now for the Script for IE 8
<!--[if lt IE 9]>
<script type="text/javascript">
// Script that runs
</script>
<![endif]-->

The first question, and most importantly, when trying this does not work. IE starts acting crazy and the script doesn't work at all. If I delete the first script and leave the second, it will work without problems. It would seem that it is <!--[if !IE]><!-->working incorrectly.

Second question: <!--[if !IE]><!-->can I target only IE 8 and below?

+5
1

HTML5 Boilerplate. IE JS CSS.

<html> . :

<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
<!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
<!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->

JavaScript:

var isIE8 = document.getElementsByClassName('lt-ie9').length;
var isIE7 = document.getElementsByClassName('lt-ie8').length;

if (isIE8) {
  ...
}

if (isIE7) {
  ...
}
+5

All Articles