събота, 9 март 2013 г.

About modernizr.js

modernizr.js is a feature detection compatibility library. It can be use to add HTML5 and CSS3 features to browsers that do not support them.

Modernizr creates an element, sets a specific style instruction on that element and then immediately retrieves it. Browsers that understand the instruction will return something sensible; browsers that don’t understand it will return nothing or “undefined”.
First create an HTML document:
<html class="no-js" lang="en">
  <head>
    <title>Hello Modernizr</title>
    <script src="modernizr.js"></script>
  </head>
  <body>
  </body>
</html>
This is how you detect if an element is supported. Let's detect a canvas element:
if (Modernizr.canvas) {
    alert("This browser supports HTML5 canvas!");
} else {
    alert("no canvas :(");
}

Няма коментари:

Публикуване на коментар