Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modernizr help?

I can't seem to get modernizr to work on my website. I have added the javascript files into a folder and called to them. I've also added no-js to the html but still nothing.

When I view source, it doesn't populate the html like it should.

I'm not using it for css3 elements yet so I don't need any fallback styles, I just want to be able to use the more semantic tags like header, nav, footer etc...

This is my document code:

<!DOCTYPE html>

<html class="no-js" lang="en">
<head>
    <meta charset=utf-8>
    <title></title>
    <!--[if IE]>
    <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
    </script>
    <![endif]-->

    <script type="text/javascript" src="/js/modernizr-1.7.min.js"></script>
like image 377
Simon Hamill Avatar asked May 17 '11 10:05

Simon Hamill


People also ask

What is modernizr used for?

Modernizr is a JavaScript library that detects which HTML5 and CSS3 features your visitor's browser supports. In detecting feature support, it allows developers to test for some of the new technologies and then provide fallbacks for browsers that do not support them.

What are features detected by modernizr?

Modernizr is a JavaScript library that automatically detects which features or, rather, web technologies are available in users' browsers. For example, Modernizr can easily detect which HTML5 and CSS3 features are being supported by the visitor's browsers.

How you can use modernizr in HTML5?

Download the Modernizr library file and then add that file to the script tag of your HTML page. Example: In this example, We will check whether our browser supports HTML5 video or not using Modernizr.

What is modernizr package?

What is Modernizr? Modernizr is a small piece of JavaScript code that automatically detects the availability of next-generation web technologies in your user's browsers.


2 Answers

Ran into this problem myself. Make sure you view the page during run-time. When you view the page source, js calls are not executed and it will not replace the no-js. If you are using Chrome then use their element inspector.

like image 94
Matthew Sprankle Avatar answered Nov 08 '22 23:11

Matthew Sprankle


It is most likely a path issue. Try temporally replacing

<script type="text/javascript" src="/js/modernizr-1.7.min.js"></script>

With

<script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/modernizr/1.7/modernizr-1.7.min.js"></script>

Or it could be working, but it's not obvious. Keep in mind you don't see the Modernizr classes when you view the source, you need a tool like Firebug on FF or the Developer Tools on Chrome to actually inspect the post-javascript code.

An additional test would be doing something like...

.borderradius body {
  background: #c00;
}

And if the background is red, then Modernizr is running.

like image 30
methodofaction Avatar answered Nov 08 '22 23:11

methodofaction