Note that there are some explanatory texts on larger screens.

plurals
  1. PODetect IE version (prior to v9) in JavaScript
    primarykey
    data
    text
    <p>I want to bounce users of our web site to an error page if they're using a version of <code>Internet Explorer</code> prior to v9. It's just not worth our time and money to support <code>IE pre-v9</code>. Users of all other non-IE browsers are fine and shouldn't be bounced. Here's the proposed code:</p> <pre><code>if(navigator.appName.indexOf("Internet Explorer")!=-1){ //yeah, he's using IE var badBrowser=( navigator.appVersion.indexOf("MSIE 9")==-1 &amp;&amp; //v9 is ok navigator.appVersion.indexOf("MSIE 1")==-1 //v10, 11, 12, etc. is fine too ); if(badBrowser){ // navigate to error page } } </code></pre> <p>Will this code do the trick?</p> <p>To head off a few comments that will probably be coming my way:</p> <ol> <li>Yes, I know that users can forge their <code>useragent</code> string. I'm not concerned.</li> <li>Yes, I know that programming pros prefer sniffing out feature-support instead of browser-type but I don't feel this approach makes sense in this case. I already know that all (relevant) non-IE browsers support the features that I need and that all <code>pre-v9 IE</code> browsers don't. Checking feature by feature throughout the site would be a waste.</li> <li>Yes, I know that someone trying to access the site using <code>IE v1</code> (or >= 20) wouldn't get 'badBrowser' set to true and the warning page wouldn't be displayed properly. That's a risk we're willing to take.</li> <li>Yes, I know that Microsoft has "conditional comments" that can be used for precise browser version detection. IE no longer supports conditional comments as of <code>IE 10</code>, rendering this approach absolutely useless.</li> </ol> <p>Any other obvious issues to be aware of?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload