Detect browser types in ASP. NET web pages

Source: Internet
Author: User

<SCRIPT type = "text/JavaScript">
// <! --
If (window. Navigator. useragent. indexof ("MSIE")> = 1 ){
// If the browser is IE
Setactivestylesheet ("browser.css ");
} Else {
If (window. Navigator. useragent. indexof ("Firefox")> = 1 ){
// If the browser is Firefox
Setactivestylesheet ("default2.css ");
} Else {
// If the browser is other
Setactivestylesheet ("newsky.css ");}
}
Function setactivestylesheet (title ){
Document. Write ("<link href = '" + title + "'Type = 'text/CSS' rel = 'stylesheet '> ");
}
// -->
</SCRIPT>

<SCRIPT type = "text/JavaScript">
// <! --
If (window. Navigator. useragent. indexof ("MSIE")> = 1 ){
// If the browser is IE
If (window. Navigator. useragent. indexof ("MSIE 6.0")> = 1)
{
Document. Write ("your browser is 60 ");
}
If (window. Navigator. useragent. indexof ("MSIE 7.0")> = 1)
{
Document. Write ("your browser is 70 ");
}
// Setactivestylesheet ("browser.css ");
} Else {
If (window. Navigator. useragent. indexof ("Firefox")> = 1 ){
// If the browser is Firefox
Setactivestylesheet ("default2.css ");
} Else {
// If the browser is other
Setactivestylesheet ("newsky.css ");}
}
Function setactivestylesheet (title ){
Document. Write ("<link href = '" + title + "'Type = 'text/CSS' rel = 'stylesheet '> ");
}
// -->
</SCRIPT>

Protected void button#click (Object sender, eventargs E)
{
System. Web. httpbrowsercapabilities browser = request. browser;
String S = "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/> ";
Response. Write (s );

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.