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 :(");
}
Няма коментари:
Публикуване на коментар