jackjohnson44
asked on
browser detection not working with changing IE browser document mode
I have to include an additional js script for IE7. I am using the IE7 developer tools to test different browsers. If you open dev tools (press F12), then there is a tab where you can switch between IE9, 8, 7.
No matter what this setting is on, I get the same info in C# using the function below. (For some reason it always shows IE7. When I try to find the version using JavaScript, I see the same version (9.0) no matter what the switch is on.
Question: How can I detect the browser and test using the IE document mode tab?
Output from js
Output from C#
No matter what this setting is on, I get the same info in C# using the function below. (For some reason it always shows IE7. When I try to find the version using JavaScript, I see the same version (9.0) no matter what the switch is on.
Question: How can I detect the browser and test using the IE document mode tab?
Output from js
console.log(navigator.userAgent);
LOG: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; MS-RTC LM 8; .NET CLR 1.1.4322; .NET4.0C; .NET4.0E; InfoPath.2)
Output from C#
Browser Capabilities
Type = IE7
Name = IE
Version = 7.0
Major Version = 7
Minor Version = 0
Platform = WinNT
Is Beta = False
Is Crawler = False
Is AOL = False
Is Win16 = False
Is Win32 = True
Supports Frames = True
Supports Tables = True
Supports Cookies = True
Supports VBScript = True
Supports JavaScript = 1.2
Supports Java Applets = True
Supports ActiveX Controls = True
public string GetBrowserInfo()
{
System.Web.HttpBrowserCapabilities browser = Request.Browser;
string browserString = "Browser Capabilities<br>"
+ "Type = " + browser.Type + "<br>"
+ "Name = " + browser.Browser + "<br>"
+ "Version = " + browser.Version + "<br>"
+ "Major Version = " + browser.MajorVersion + "<br>"
+ "Minor Version = " + browser.MinorVersion + "<br>"
+ "Platform = " + browser.Platform + "<br>"
+ "Is Beta = " + browser.Beta + "<br>"
+ "Is Crawler = " + browser.Crawler + "<br>"
+ "Is AOL = " + browser.AOL + "<br>"
+ "Is Win16 = " + browser.Win16 + "<br>"
+ "Is Win32 = " + browser.Win32 + "<br>"
+ "Supports Frames = " + browser.Frames + "<br>"
+ "Supports Tables = " + browser.Tables + "<br>"
+ "Supports Cookies = " + browser.Cookies + "<br>"
+ "Supports VBScript = " + browser.VBScript + "<br>"
+ "Supports JavaScript = " +
browser.EcmaScriptVersion.ToString() + "<br>"
+ "Supports Java Applets = " + browser.JavaApplets + "<br>"
+ "Supports ActiveX Controls = " + browser.ActiveXControls
+ "<br>";
return browserString;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.