For IE7 users, I want to put in some specific "Please upgrade now" banner. I thought i had this but i found out my banner was popping up on people who had IE8 but had compatibility mode turned on by default.
Is there anyway to differentiate between these two situations so I can change my message from:
Please update from IE7 to You are using IE8 but you are using compatibility mode, please switch this off
Here is the code that i am using now in my View:
You are using <b><% = Request.Browser.Browser + ", Version: " + Request.Browser.Version%>
but if I test in IE8 with compatability view, by using the above code or this code on the client side:
<!--[if lte IE 7]>
it returns true and shows up as IE7. How can i differentiate the two ?
According to user-agents.org and some of the discussion linked by other answers, you can differentiate between the three cases by checking the user agent string you've received.
For MSIE 7.0: Check for MSIE 7.0
and the lack of Trident
For example: Mozilla/4.0 (compatible;
MSIE 7.0;
Windows NT 5.1; GTB5; User-agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; http://bsalsa.com) ; .NET CLR 2.0.50727)
For MSIE 8.0 in compatability mode: Check for MSIE 7.0
and the presence of Trident/4.0
For example: Mozilla/4.0 (compatible;
MSIE 7.0;
Windows NT 6.1;
Trident/4.0;
SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; Tablet PC 2.0)
For MSIE 8.0 in standard mode: Check for MSIE 8.0
For example: Mozilla/4.0 (compatible;
MSIE 8.0;
Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648)
To perform these checks, consult the following tutorial, replacing all of this nonsense about iPhones and mobile devices with the browsers you're checking for. :)
Best of luck with your application.
Putting this
"<meta http-equiv="X-UA-Compatible" content="IE=8">"
in your header will make IE8 not load up in compatability mode
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With