0

If a user is on IE 7 and I read

<% = Request.Browser.Version %>

I get 7.0

if they have IE 9 and are on compatibility view, I get the same thing.

Is there anything in Request.Browser that can differentiate between a real IE7 user and a user that is using IE8 or IE9 but in compatibility mode?

Cœur
  • 37,241
  • 25
  • 195
  • 267
leora
  • 188,729
  • 360
  • 878
  • 1,366
  • It might help to know why you'd need to know that on the server-side. – rossisdead Sep 04 '12 at 20:42
  • http://stackoverflow.com/questions/10213639/differentiate-ie7-browser-and-browser-in-ie7-compatibility-mode – Omer Bokhari Sep 04 '12 at 20:47
  • @rossisdead - because i want to give a different warning. .Either "upgrade" or "turn off compatibility mode" – leora Sep 04 '12 at 20:55
  • 1
    If you tell them to upgrade to Firefox, it will be applicable in both cases. – ctrl-alt-delor Sep 04 '12 at 21:13
  • @richard - agree but if they are using IE9, they don't need to upgrade their browser, they just need to turn off compatibility mode. this is a much simpler ask :) – leora Sep 09 '12 at 13:57
  • Here is some code that will do it, `You appear to be running Internet explorer 7. To use this site you will need to upgrade to a newer browser. (If you are running Internet Explorer 9, in (in)comparability mode then please switch to normal mode, else upgrade here http://www.mozilla.org/en-US/firefox/new/.` This code should run on the latest version of human, with English language module installed. – ctrl-alt-delor Sep 09 '12 at 18:39

1 Answers1

1

It would be better to do this on the client side using JavaScript. You can use something like this:

http://code.google.com/p/ie6-upgrade-warning/

You can tweak it to whatever you want.

If your goal is simply to make sure the user is not in compatibility mode, then you can use either the meta tag or http header version of X-UA-COMPATIBLE:

<html>
   <head>
       <meta http-equiv="X-UA-Compatible" content="IE=Edge" >
   </head>
   <body>
       <p>Content goes here.</p>
   </body>
</html> 
Erik Funkenbusch
  • 92,674
  • 28
  • 195
  • 291
  • This is fine except you didn't answer the question. Is there a way to differentiate the two (the actual IE7 browser from IE8+ but in compatibility mode) from javascript? – leora Sep 09 '12 at 13:58
  • @leora - You are looking at this the wrong way. YOU are in control over the mode the browser renders in. If you want the site to render in standards mode, then you need to use a proper doctype, and optionally use the `X-UA-COMPATIBLE` meta tag or http header, which will force IE to render in standards mode. – Erik Funkenbusch Sep 09 '12 at 19:12
  • thanks for the clarification. So this will trump any browser settings (for example there is the setting in IE to render all intranet sites in compatibility mode. which one trumps the other? – leora Sep 10 '12 at 11:34
  • @leora - Yes, X-UA-COMPATIBLE trumps user setting. If it's there, the user doesn't even get the broken document to enable compatibility mode, and yes it trumps the intranet sits mode. – Erik Funkenbusch Sep 10 '12 at 16:00
  • thanks for the info . . can you update your answer to highlight this point and i will mark it as accepted .. – leora Sep 10 '12 at 17:12