JavaScript and asp.net determine browser type

Source: Internet
Author: User

Below we provide three kinds of JavaScript tutorials to determine browser type and ASP tutorial. NET Judgment browsing type, below we look at JS Judge user browsing 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;
}

Get the type of browser 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 type of browser: 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 Two

function Getbrowser () {
var otype = "";
if (Navigator.userAgent.indexOf ("MSIE")!=-1) {
Otype= "IE";
}else if (navigator.userAgent.indexOf ("Firefox")!=-1) {
Otype= "FIREFOX";
}
return otype;
}  


asp.net tutorial to determine browser type

if (Page.Request.Browser.EcmaScriptVersion.Major > 0 && Page.Request.Browser.W3CDomVersion.Major > 0)//Decide whether to support script
{
Response.Write ("Browser name and version number:" + Page.Request.Brow Ser. Type + "<br/>");
Response.Write ("browser version number:" + Page.Request.Browser.Version + "<br/>");
Response.Write ("browser major version Number:" + 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.