.load()不适用于IE

时间:2011-09-27 09:20:09

标签: javascript jquery internet-explorer load

我正试图在这个网站上进行一些动态工作http://peps.sqps.nl 一切似乎都运行良好,直到我在IE中测试网站,它只是不提供任何内容。

我使用的js如下:

$(document).ready(function(){
$('li.navItem a').click(function(){
    var url = $(this).attr('href');

    $('article').load(url + ' article', function(){
        $('article').fadeTo(1200, 1);
    });

    return false;
});
});

动态部分的html如下所示,其中<article></article>部分应该动态地动作。

<section id="content">
  <div id="article">
    <article>
         content is in here
    </article>
  </div>
</section>

这里给出的类似问题的解决方案没有解决这个问题 有人有什么想法吗?

日Thnx!

3 个答案:

答案 0 :(得分:1)

您的网址看起来很糟糕。

url = "http://site.com/path/to/page"
load_url = url + ' article'
alert(load_url); // Displays "http://site.com/path/to/page article"

这是你真正想要的吗?

答案 1 :(得分:0)

IE可能正在缓存您的代码。

请参阅此帖子:jQuery's .load() not working in IE - but fine in Firefox, Chrome and Safari

答案 2 :(得分:0)

添加.each(function(){...});在.load之后,它应该适用于IE和Chrome。

        $('#<%=image1.ClientID %>').load(function () {
            //things to do
        }).each(function () {
            if (this.complete) $(this).load();
        });