0

I'm wondering how to detect IE11 and change css to debug by Jquery or by <style type="text/css">

the conditional statements is not working <!--[if IE 11]-->...somecode...<![endif]--> as well the jquery is neither too. :(

like

<script type="text/javascript">
  if(//IE11){
    <style>
    #sms-cont {
    height:315px;
    }
    </style>
   }
</script>

or by

   if(//IE11) {
    $(document).ready(function () {
    $("#sms-cont").css({
        "width": "385px",
        "height": "315px"
      });
   });
  }       

any idea how to detect it which realy works and change any code or put css to debug?

  • 1
    conditional statements where removed from IE10 and above, and it no longer works to just check for MSIE in the user agent. There seems to be an answer here -> http://stackoverflow.com/questions/17907445/how-to-detect-ie11 – adeneo Dec 24 '13 at 09:01
  • I alredy saw this answer there thats not getting help ;( –  Dec 24 '13 at 09:03
  • Possibly duplicate of [this issue](http://stackoverflow.com/a/18922329/2525067) – Alex Dec 24 '13 at 09:39
  • 1
    Another dup: http://stackoverflow.com/questions/18871760/how-to-detect-ie-11-with-javascript-in-asp-net – Spudley Dec 24 '13 at 09:55

3 Answers3

0

You can use a solution such as http://whichbrowser.net/

tim.baker
  • 3,109
  • 6
  • 27
  • 51
  • it shows real info , but how to use it with if statement like my code mentioned in question ? –  Dec 24 '13 at 10:45
0

I just found my own questions answer. here is the solution

    if(navigator.userAgent.match(/Trident.*rv:11\./)) {

 $(document).ready(function(){
    //some code stuff goes here
  }); 
 }

and its 100% working no doubt. NOTE: that in this between code you can put jquery or javascript code.

-1

With the help of below code you get the different class according to different version of IE.

<!--[if lt IE 8]> <html class="ie7 oldie"> <![endif]-->
<!--[if IE 8]>    <html class="ie8 oldie"> <![endif]-->
<!--[if IE 9]>    <html class="ie9 oldie"> <![endif]-->
<!--[if gt IE 10]><html class="ie11 oldie"> <![endif]-->
<html class="">
<!--<![endif]-->
Rakesh Kumar
  • 2,705
  • 1
  • 19
  • 33
  • Will somebody help me to solve this problem ;( ??? all of this conditions is not working as I said the jquery is neither , I m using wordpress 3.8 . –  Dec 24 '13 at 10:06
  • @Mr.beginner - the ideal solution is to understand why you need the IE detection, and work from there to find a solution that doesn't require any browser detection. IE11 is actually pretty good at modern web standards, so there's very little real need to detect it. Unfortunately, the code you've shown us doesn't give us enough info to understand why you want to detect IE11. If you gave us a bit more info in the question we might be able to give you an alternative solution. – Spudley Dec 24 '13 at 10:19