JavaScript code used to determine the browser type of the Client

Source: Internet
Author: User

CopyCode The Code is as follows: <SCRIPT type = "text/JavaScript">
/* Detailed method 1 */
Function checkbrowser ()
{
VaR APP = navigator. appname;
VaR verstr = navigator. appversion;
// Firefox
If (App. indexof ('netscape ')! =-1)
{
Alert ("you are using the Netscape or Firefox browser. ");
}
Else if (App. indexof ('Microsoft ')! =-1)
{
If (verstr. indexof ("MSIE 3.0 ")! =-1 | verstr. indexof ("MSIE 4.0 ")! =-1 | verstr. indexof ("MSIE 5.0 ")! =-1 | verstr. indexof ("MSIE 5.1 ")! =-1)
{
Alert ("you are using a browser earlier than ie6.0 .");
}
Else
{
Alert ("you are using ie6.0 or later browsers .");
}
}
}
/* Concise method 2 */
Function checkbrowser1 ()
{
If (window. Navigator. useragent. indexof ("MSIE")> = 1)
// If the browser is IE
{
Alert ("IE browser ");
}
Else // If the browser is Firefox
{
If (window. Navigator. useragent. indexof ("Firefox")> = 1)
{
Alert ("fixfox Browser ");
}
}
}
// Call
Checkbrowser ();
Checkbrowser1 ();
</SCRIPT>

JavaScript to obtain client information Copy code The Code is as follows: Document. Write ("Screen Resolution :")
Document. Write (screen. Width + "*" + screen. Height)
Document. Write ("<br/> ")
Document. Write ("available view area :")
Document. Write (screen. availwidth + "*" + screen. availheight)
Document. Write ("<br/> ")
Document. Write ("color depth :")
Document. Write (screen. colordepth)
Document. Write ("<br/> ")
Document. Write ("buffer depth :")
Document. Write (screen. bufferdepth)
Document. Write ("<br/> ")
Document. Write ("devicexdpi :")
Document. Write (screen. devicexdpi)
Document. Write ("<br/> ")
Document. Write ("deviceydpi :")
Document. Write (screen. deviceydpi)
Document. Write ("<br/> ")
Document. Write ("logicalxdpi :")
Document. Write (screen. logicalxdpi)
Document. Write ("<br/> ")
Document. Write ("logicalydpi :")
Document. Write (screen. logicalydpi)
Document. Write ("<br/> ")
Document. Write ("fontsmoothingenabled :")
Document. Write (screen. fontsmoothingenabled)
Document. Write ("<br/> ")
Document. Write ("pixeldepth :")
Document. Write (screen. pixeldepth)
Document. Write ("<br/> ")
Document. Write ("updateinterval :")
Document. Write (screen. updateinterval)
Document. Write ("<br/> ")

Related Article

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.