我有一小段代码,它只是从我们的一个网站上拉入一个新闻发布:
$(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:
<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中运行良好。有人能帮上忙吗?
发布于 2012-01-11 00:05:06
"IE在增强JS的正确性方面做得很好。它在{'aaa','bbb',}上会因为尾随的逗号而失败,FF和Chrome会忽略这个错误。有时发现问题会让人抓狂,但一旦你发现了问题,你的代码就会变得更好。“
--谢谢,大卫,这就是问题所在。
https://stackoverflow.com/questions/7677768
复制相似问题