JavaScript browser type and version number detection code (compatible with multiple browsers) _javascript tips

Source: Internet
Author: User
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> <ptml xmlns=" http://www.w3.org/1999/xhtml "> <pead> <meta content=" text/html; Charset=utf-8 "http-equiv=" content-type/> <title>javascript detects browser type and version number (compatible with browsers) </title> <script language= "JavaScript" type= "Text/javascript" > var uA = navigator.useragent; var browsertype = "Unknown"; if (Ua.indexof ("opera") >-1) {BrowserType = "opera"; else if (Ua.indexof ("Safari") >-1) {BrowserType = "safari"; else if (Ua.indexof ("Konqueror") >-1) {BrowserType = "Konqueror"; else if (Ua.indexof ("Gecko") >-1) {BrowserType = "Mozilla"; else if (Ua.indexof ("MSIE") >-1) {BrowserType = "Internet Explorer"; }//window.alert (BrowserType); document.write (BrowserType); document.write (""); document.write (document.lastmodified); Displays the modified date of the page document.write (""); document.write (navigator.useragent);Display Client Environment Parameters document.write (""); document.write ("H,w:" +screen.availheight+ "x" +screen.availwidth+ "Pixels")//monitor size/monitor size function Screenwh () { var Getscreen=document.getelementbyid (' Screenwh '); getscreen.value=screen.availheight+ "X" +screen.availwidth; var Divscreen=document.getelementbyid (' Screenswh '); divscreen.value=screen.availheight+ "x" +screen.availwidth+ "Pixels"; window.screen.height+ "+" +window.screen.width; } </script> </pead> <body onload= "JAVASCRIPT:SCREENWH ();" > <input type= "text" id= "Screenwh"/> <input ' button ' type= ' onclick= () ' Notempty ' Form value= ' Checker <div id= "SCREENSWH" ></div> </body> </ptml>
[Ctrl + A All SELECT Note: If the need to introduce external JS need to refresh to perform]

Related articles:
JavaScript detects browser types and versions of code
JavaScript Browser Detection Code Lite version
JavaScript determines browser type and version
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.