0

I have a script, similar to this, to block users using Internet Explorer 7 and 8 from accessing my website. I got a message from a customer saying that they were not able to access the website despite using IE 10. I asked the client to go to a website which would allow him to retrieve his user agent and send it to me.

Customers user agent:

Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)

I'm unsure why the script would block the customer. Below is a small adaptation of the script used to detect the browser version.

//Detect broswer
if (navigator.appName == 'Microsoft Internet Explorer'){


    var ua = navigator.userAgent;
    var ver  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (ver.exec(ua) != null){
        ver = parseFloat( RegExp.$1 );
    }

    if ( ver > -1 )
    {
        if ( ver >= 9.0 ){
            //msg = "You're using a recent copy of Internet Explorer.";
            //alert( msg );
        }
        else {
            $("#inputSection").fadeOut( 'slow', function() {
                $("#inputSection").replaceWith(
                        "We have detected that you are using Internet Explorer version: " + ver +", which is no longer supported. <br>" +
                                "Please upgrade your browser to the latest version, or use a different browser."
                );
            });

        }
    }


}
Tsume
  • 907
  • 2
  • 11
  • 21
  • 1
    Why not use `` in your HTML? – ntzm May 12 '14 at 12:06
  • 1
    It appears they have Compatibility View enabled, either explicitly for your site and/or all sites. See this thread for more detail on checking for/detecting IE in Compatibility View mode: http://stackoverflow.com/questions/5825385/javascript-can-i-detect-ie9-if-its-in-ie7-or-ie8-compatibility-mode/5825518#5825518 – Stevangelista May 12 '14 at 12:16
  • @Stevangelista That is likely the solution, but I have an issue with coding my javascript to use that solution. Most of the solutions online use the if(navigator.userAgent.indexOf("Trident/5")>-1). Problem is that is for a specific IE version. Would you happen to know how I can check the Trident version for IE 9 and higher in a single statement? – Tsume May 13 '14 at 20:05
  • Consider this listing of the User Agent & other document properties: http://i.stack.imgur.com/yzXVq.png - what is your desired behavior for a user who has IE9+ & Compatibility View enabled? Block them as if they are an IE8- user or display a unique message requesting they disable Compatibility View? – Stevangelista May 14 '14 at 02:59
  • @Stevangelista If the script detects a IE9+ browser running in compatibility mode, I wish not to block it. I'm looking for solution where without doing a bunch of if statements checking the trident related to each version, how can I check for a trident of 5 or greater. – Tsume May 14 '14 at 06:58

0 Answers0