Conditional JavaScript

From Wiki @ Karl Jones dot com
Revision as of 11:38, 10 May 2016 by Karl Jones (Talk | contribs) (Created page with "In web design, '''conditional JavaScript''' refers to JavaScript which is conditional: it is used under some conditions, but not others. == Internet Explorer conditi...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

In web design, conditional JavaScript refers to JavaScript which is conditional: it is used under some conditions, but not others.

Internet Explorer conditional JavaScript

Internet Explorer has its own conditional rules, which can apply to all versions of Internet Explorer, or certain specified versions.

All other browsers will ignore these conditional rules.

In the example below, if lt IE 9 indicates that Internet Explorer which is less than version nine (lt IE 9) should use the two external JavaScript files:

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

The above example is from a typical Bootstrap framework template.

See also