Js/jquery/html Front-end development common to fragment code (always updated)

Source: Internet
Author: User
Tags html comment

1.IE Conditional Comment

Introduction to Conditional annotations

    1. The conditional annotation in IE (Conditional comments) has excellent distinguishing ability to IE's version and IE non ie, it is the hack method commonly used in web design.
      Conditional annotations can only be used for IE5 above, IE10 not supported.

    2. If you install more than one IE, the conditional comment will be the highest version of IE as standard.

    3. The basic structure of the conditional comment is the same as the HTML comment (<!––>). Browsers outside of IE will therefore treat them as plain annotations and ignore them entirely.

    4. IE will determine whether the content in the conditional comment is parsed as if the normal page content is parsed, based on the IF condition.

Example of how conditional annotations are used

<!–[if IE 5]>Only IE5.5 visible<![endif]–><!–[if GT IE 5.5]>Only IE 5.5 above visible<![endif]–><!–[if lt IE 5.5]>Only IE 5.5 below visible<![endif]–><!–[if GTE IE 5.5]>IE 5.5 and above visible<![endif]–><!–[if LTE IE 5.5]>IE 5.5 and below are visible<![endif]–><!–[if! IE 5.5]>ie visible in non IE 5.5<![endif]–>

Excerpt Link: http://segmentfault.com/blog/liangyi/1190000002409131

2.html code dynamically loaded into the page with JS
<type= "text/html"  ID= "t-pclist">// here is the HTML code you want to put, such as the content of a div </ Script >

Add the above JS dynamic to the page

$ (function() {var s=$ ("#T-pclist"). html ();   get the HTML content of JS $ (". Picscroll-left. BD"). HTML (s); // The content of S is placed in the BD Thisstyle (); // Execute a function });

3.js determine whether a user is accessing a PC or mobile
varBrowser={versions:function(){        varU = navigator.useragent, app =navigator.appversion; varSuseragent =navigator.useragent; return{trident:u.indexof (' Trident ') >-1, Presto:u.indexof (' Presto ') >-1, Ischrome:u.indexof ("Chrome") >-1, Issafari:!u.indexof ("Chrome") >-1 && (/webkit|khtml/). Test (U), IsSafari3:!u.indexof ("Chrome") >-1 && (/webkit|khtml/). Test (U) && u.indexof (' WEBKIT/5 ')! =-1, Webkit:u.indexof (' AppleWebKit ') >-1, Gecko:u.indexof (' Gecko ') >-1 && u.indexof (' khtml ') = =-1, Mobile:!! U.match (/applewebkit.*mobile.*/), iOS:!! U.match (/\ (i[^;] +;( U;)? Cpu.+mac OS x/), Android:u.indexof (' Android ') >-1 | | U.indexof (' Linux ') >-1, Iphone:u.indexof (' IPhone ') >-1, Ipad:u.indexof (' IPad ') >-1, Iwinphone:u.indexof (' Windows Phone ') >-1        }; }()}if(Browser.versions.mobile | |Browser.versions.iWinPhone) {window.location= "http:/www.baidu.com/m/";} 

4.js how to tell if a user is using a browser

Determine if the browser is built-in based on the keyword Micromessenger. The judging function is as follows:

function isweixin () {     var ua = window.navigator.userAgent.toLowerCase ();      if (Ua.match (/micromessenger/i) = = ' Micromessenger ')         {returntrue;     } Else {         returnfalse;     

See the Rainbow after the rain

Source: http://www.cnblogs.com/moqiutao/

If you feel that this article is helpful to your study, please support and encourage more.

Js/jquery/html Front-end development common to fragment code (always updated)

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.