1

Before I get chided over this being an old question , I have done my research on it and conditional statements in the HTML seem to be a strict no with IE10+ no longer supporting them and hence any condition statements I write using [if lt IE 9] are not adhered to when using IE10 and above. So in my opinion this method is crossed.

I didn't find any clear answer for if using 1.8+ over the browser with the version and don't want to use raw javascript. I could use modernizer but I just have one line of code to include in the condition and don't want to add in the extra load if that were possible to be implemented using some jquery snippet.

Suggestions?

Rohan
  • 3,296
  • 2
  • 32
  • 35
  • 2
    Why do you care if IE10 doesn't support it? you only care about IE8. IE10 will ignore it just like other modern browsers. (correct me if i'm wrong?) – Kevin B Mar 03 '14 at 17:13
  • Whatever condition I write( – Rohan Mar 03 '14 at 17:14
  • 7
    Consider using browser *feature* detection instead of *version* detection (e.g. [modernizr](http://modernizr.com/)). – maerics Mar 03 '14 at 17:14
  • @maerics - would it be wise to load all that javascript for just 1 line of code I need to include in the condition - which is why i wanted to do away with it using some simple jquery code if it exists. – Rohan Mar 03 '14 at 17:15
  • This might be helpful : http://stackoverflow.com/questions/19352522/how-can-i-detect-browser-type-using-jquery – anurag_29 Mar 03 '14 at 17:20

2 Answers2

3

Ok, so after a little research, decided to use neither JQuery nor modernizer and am utilizing browser capabilities on IE9+ to write conditional code for I8 and below -

<script> 
   if(!document.addEventListener){
       //code for IE8 and below
    }
</script> 

Kind of a hack but it works and fingers crossed :)

Rohan
  • 3,296
  • 2
  • 32
  • 35
0

Adding more info,

http://tanalin.com/en/articles/ie-version-js/

IE versions Condition to check for

IE 10 or older - document.all
IE 9 or older - document.all && !window.atob
IE 8 or older - document.all && !document.addEventListener
IE 7 or older - document.all && !document.querySelector
IE 6 or older - document.all && !window.XMLHttpRequest
IE 5.x - document.all && !document.compatMode

Hope it helps

Prem
  • 119
  • 1
  • 4