首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >这在IE中不起作用...有没有人能解释一下原因?

这在IE中不起作用...有没有人能解释一下原因?
EN

Stack Overflow用户
提问于 2011-10-07 00:51:36
回答 1查看 249关注 0票数 1

我有一小段代码,它只是从我们的一个网站上拉入一个新闻发布:

代码语言:javascript
复制
    $(document).ready(function(){
        items = [];
        curr_item = 0;
        $.getJSON('/press-release/feed/', function(data){
            items = data;
            render(0);
            next = setInterval(next_release, 5000);
    });

    function next_release() {
        //make sure we can't fall off the end of the array
        if(curr_item == items.length-1)
            curr_item = 0;
        else
            curr_item++;

        render(curr_item);
    }

    function render( index ) {
        item = items[index].fields;
        $('#ticker-text a').fadeOut('slow', function(){
            $(this).attr('href', '/press-release/' + item.slug).text(item.title);
            $(this).fadeIn('slow');
        });
     }

    });

下面是HTML:

代码语言:javascript
复制
    <div id="news-ticker">
        <span id="ticker-text"><a href=""></a></span>
         <ul>
            <li><a href=""></a></li>
         </ul>
    </div>

由于某些原因,这不能在IE中从JSON字符串中呈现新闻稿文本,但它在safari、chrome、firefox、opera中运行良好。有人能帮上忙吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-11 00:05:06

"IE在增强JS的正确性方面做得很好。它在{'aaa','bbb',}上会因为尾随的逗号而失败,FF和Chrome会忽略这个错误。有时发现问题会让人抓狂,但一旦你发现了问题,你的代码就会变得更好。“

--谢谢,大卫,这就是问题所在。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7677768

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档