0

当我单击站点中的链接时,它可以在主要浏览器中运行,但 IE9 及更低版本无法运行。我点击链接,没有任何反应!控制台说:“event.returnValue 已弃用。请改用标准 event.preventDefault()。”

我正在使用这个网站上的这个方法:http: //sudojesse.github.io/dynamic-page/index.html

当我在 IE9 中使用这个网站并降低它时它可以工作(刷新页面,但它可以工作!)。我究竟做错了什么?

编辑:将所有内容放在子文件夹中时,它可以工作!可能是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>
4

2 回答 2

0

现在可以了!结果是一个脚本(jquery lavalamp)阻止了它,但只在 IE 中!国家安全局应该删除那个浏览器!!

于 2013-12-22T10:04:41.920 回答
0

尝试:

$( "a" ).on("click", function(e) {
    _link = $(this).attr("href");
    history.pushState(null, null, _link);
    loadContent(_link);
    e.preventDefault();
});
于 2013-12-21T23:42:29.870 回答