Use Css/javascript to determine browser type

Source: Internet
Author: User

method One:

<!--[If LTE IE 6]> <link rel= "stylesheet" type= "Text/css" href= "Images/style_ie5.css"/> <! [endif]–> <!--[if IE 6]> <link rel= "stylesheet" type= "Text/css" href= "Images/style_ie6.css"/> <! [endif]--> <!--[if IE 7]> <link rel= "stylesheet" type= "Text/css" href= "Images/style_ie7.css"/> <! [endif]-->

Applicable browser: IE5 above the IE browser

Using Technology: Conditional comments

Where to use: in HTML code (note not in CSS)

Comparison character:

LTE: Is the shorthand for less than or equal to, meaning less than or equal to.
LT: It is the shorthand for less than, which means less than.
GTE: is the shorthand for greater than or equal to, which is greater than or equal to the meaning.
GT: is the shorthand for greater than, which means greater than.
! : Is not equal to the meaning, and JavaScript is not equal to the same judge character

Method Two:

#example {color:red;} /*firefox*/* HTML #example {Color:blue} /*ie6*/*+html #example {color:green;} /*ie7*/

Place of Use: CSS

Method Three:

<link type= "Text/css" rel= "stylesheet" href= "Css/screen.css"/> <link type= "text/css" rel= "stylesheet" href= " Css/screen.css "/> <script language=" JavaScript type= "Text/javascript" > <!--//depending on the browser to select CSS if (!window. XMLHttpRequest) {setactivestylesheet ("ie6.css");//ie6}else if (window. ActiveXObject) {setactivestylesheet ("ie7.css");//ie7} else {setactivestylesheet ("firefox.css");//mozilla FireFox, Safari, etc.} function Setactivestylesheet (filename) {var path = document.getElementsByTagName ("link") [1].href; document.getElementsByTagName ("link") [1].href= "css/" +filename; }//--> <script>

This is the use of different versions of the browser to create XMLHttpRequest different ways to choose different CSS

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.