{"id":2661,"date":"2016-06-06T07:22:38","date_gmt":"2016-06-06T07:22:38","guid":{"rendered":"http:\/\/truelogic.org\/wordpress\/?p=2661"},"modified":"2016-06-06T07:22:38","modified_gmt":"2016-06-06T07:22:38","slug":"ie-version-detection-in-javascript","status":"publish","type":"post","link":"https:\/\/truelogic.org\/wordpress\/2016\/06\/06\/ie-version-detection-in-javascript\/","title":{"rendered":"IE  version detection in Javascript"},"content":{"rendered":"            <script type=\"text\/javascript\" src=\"https:\/\/truelogic.org\/wordpress\/wp-content\/plugins\/wordpress-code-snippet\/scripts\/shBrushJScript.js\"><\/script>\n<p>Detection of the\u00a0 newer versions of IE is much more messy than before. Since IE uses the Trident rendering engine, each IE version uses a particular Trident version, which is what the sample script below does.<\/p>\n<p>&nbsp;<br \/>\n<pre class=\"brush: js\">&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;script&gt;\r\n\tfunction showInfo() {\r\n\t\tvar nav= (navigator.userAgent);\r\n\t\tif (nav.indexOf(&quot;Trident\/7.0&quot;) &gt; -1) {\r\n\t\t\talert(&quot;IE 11.0&quot;);\r\n\t\t}\r\n\t\telse if (nav.indexOf(&quot;Trident\/6.0&quot;) &gt; -1) {\r\n\t\t\talert(&quot;IE 10.0&quot;);\r\n\t\t}\r\n\t\telse if (nav.indexOf(&quot;Trident\/5.0&quot;) &gt; -1) {\r\n\t\t\talert(&quot;IE 9.0&quot;);\r\n\t\t}\r\n\t\telse if (nav.indexOf(&quot;Trident\/4.0&quot;) &gt; -1) {\r\n\t\t\talert(&quot;IE 8.0&quot;);\r\n\t\t}\r\n\t\telse\r\n\t\t\talert(&quot;IE is older than 8.0&quot;);\r\n\t\r\n\t}\r\n\t\r\n\r\n\r\n&lt;\/script&gt;\r\n&lt;\/head&gt;\r\n&lt;body&gt;\r\n\t&lt;br&gt;\r\n\t&lt;a href=&quot;#&quot; onclick=&quot;showInfo();&quot;&gt;Show Info&lt;\/a&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;<\/pre><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"mh-excerpt\"><p>Detection of the\u00a0 newer versions of IE is much more messy than before. Since IE uses the Trident rendering engine, each IE version uses a <a class=\"mh-excerpt-more\" href=\"https:\/\/truelogic.org\/wordpress\/2016\/06\/06\/ie-version-detection-in-javascript\/\" title=\"IE  version detection in Javascript\">[&#8230;]<\/a><\/p>\n<\/div>","protected":false},"author":1,"featured_media":2664,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-2661","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript"],"_links":{"self":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2661","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/comments?post=2661"}],"version-history":[{"count":3,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2661\/revisions"}],"predecessor-version":[{"id":2665,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/posts\/2661\/revisions\/2665"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media\/2664"}],"wp:attachment":[{"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/media?parent=2661"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/categories?post=2661"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/truelogic.org\/wordpress\/wp-json\/wp\/v2\/tags?post=2661"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}