modernizr not working with IE9 and lower

521 views Asked by At

When I click links in my site it works in major browsers, but IE9 and lower do not work. I click the links and nothing happens! Console says: "event.returnValue is deprecated. Please use the standard event.preventDefault() instead."

I'm using this method from this website: http://sudojesse.github.io/dynamic-page/index.html

when I use this website in IE9 and lower it works (with refreshing the page, but it works!). What am I doing wrong?

EDIT: When putting everything in a subfolder it works! Could it be something with htacess?

  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<script type='text/javascript' src='js/modernizr.js'></script>
<script>$(function() {

if(Modernizr.history){

var newHash      = "",
    $mainContent = $("#main-content"),
    $pageWrap    = $("#page-wrap"),
    baseHeight   = 0,
    $el;

$pageWrap.height($pageWrap.height());
baseHeight = $pageWrap.height() - $mainContent.height();

$( "a" ).on("click", function() {
    _link = $(this).attr("href");
    history.pushState(null, null, _link);
    loadContent(_link);
    return false;
});

function loadContent(href){
    $mainContent
            .find("#guts")
            .fadeOut(200, function() {
                $mainContent.hide().load(href + " #guts", function() {
                    $mainContent.fadeIn(200, function() {
                        $pageWrap.animate({
                            height: baseHeight + $mainContent.height() + "px"
                        });
                    });

                });
            });
}

$(window).bind('popstate', function(){
   _link = location.pathname.replace(/^.*[\\\/]/, ''); //get filename only
   loadContent(_link);
});
} // otherwise, history is not supported, so nothing fancy here.
});</script>
2

There are 2 answers

2
Leeish On

Try:

$( "a" ).on("click", function(e) {
    _link = $(this).attr("href");
    history.pushState(null, null, _link);
    loadContent(_link);
    e.preventDefault();
});
0
user3086671 On

It now works! Turns out a script (jquery lavalamp) was blocking it, but only in IE! The NSA should delete that browser!!