Javascript and asp.net determine the browser type

Source: Internet
Author: User

Below we provide three types of javascript to determine the browser type and asp.net to determine the browser type. Next let's take a look at js to determine that the user's browser is firfox, msie, etc.

Below we provide three javascript tutorials to determine the browser type and asp tutorial. net to determine the browser type. Next let's take a look at js to determine that the user's browser is firfox, msie, etc.

Function getPageCharset (){
Var charSet = "";
Var oType = getBrowser ();
Switch (oType ){
Case "IE ":
CharSet = document. charset;
Break;
Case "FIREFOX ":
CharSet = document. characterSet;
Break;
Default:
Break;
}
Return charSet;
}

// Obtain whether the browser type is IE or Firefox

Function getBrowser (){
Var oType = "";
If (navigator. userAgent. indexOf ("MSIE ")! =-1 ){
OType = "IE ";
} Else if (navigator. userAgent. indexOf ("Firefox ")! =-1 ){
OType = "FIREFOX ";
}
Return oType;
}


How to determine the browser type: isFireFox msie

 

Function isIe ()
{
Var I = navigator. userAgent. toLowerCase (). indexOf ("msie ");
Return I> = 0;
}
Funciton isFireFox ()
{
Var I = navigator. userAgent. toLowerCase (). indexOf ("firefox ");
Return I> = 0;
}

Js 2

 

Function getBrowser (){
Var oType = "";
If (navigator. userAgent. indexOf ("MSIE ")! =-1 ){
OType = "IE ";
} Else if (navigator. userAgent. indexOf ("Firefox ")! =-1 ){
OType = "FIREFOX ";
}
Return oType;
}


How to determine the browser type in the asp.net tutorial

 

If (Page. Request. Browser. EcmaScriptVersion. Major> 0 & Page. Request. Browser. W3CDomVersion. Major> 0) // you can check whether scripts are supported.
{
Response. Write ("Browser name and version:" + Page. Request. Browser. Type + "<br/> ");
Response. Write ("Browser Version:" + Page. Request. Browser. Version + "<br/> ");
Response. Write ("main Browser version:" + Page. Request. Browser. MajorVersion + "<br/> ");
Response. Write ("Browser name:" + Page. Request. Browser. Browser );
}

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.