我正在使用此脚本从博客加载新闻,使用 Google AJAX 提要 API。如何从 Google Ajax FEED Api 设置标题的字符数?下面是我的脚本
HTML
<div id="feeddiv">
</div>
脚本
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("feeds", "1") //Load Google Ajax Feed API (version 1)
</script>
<script type="text/javascript">
var feedcontainer=document.getElementById("feeddiv")
var feedurl="http://anatomicshoes.wordpress.com/feed/"
var feedlimit=4
var rssoutput="<ul>"
function rssfeedsetup(){
var feedpointer=new google.feeds.Feed(feedurl) //Google Feed API method
feedpointer.setNumEntries(feedlimit) //Google Feed API method
feedpointer.load(displayfeed) //Google Feed API method
}
function displayfeed(result){
if (!result.error){
var thefeeds=result.feed.entries
for (var i=0; i<thefeeds.length; i++){
var pubDate = thefeeds[i].publishedDate;
var date = new Date(pubDate);
var months = Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
var string = date.getDate() + "/" + months[date.getMonth()] + "/" + date.getFullYear()
rssoutput+="<li><span>•</span> <small>" + string + "</small> - <a href='" + thefeeds[i].link + "' target='_blank'>" + thefeeds[i].title + "</a></li>"
}
rssoutput+="</ul>"
feedcontainer.innerHTML=rssoutput
} else
alert("Erro ao carregar as notícias!")
}
window.onload=function(){
rssfeedsetup()
}
</script>
这是输出:
• 18/04/2013 - Vincent Ko features the Jardins…
• 12/04/2013 - Stay stylish this Spring…
• 10/04/2013 - Coming soon….
• 5/04/2013 - Introducing the Jardins – A development in Ethical footwear!
但我想要这样的东西(不是整个标题):
• 18/04/2013 - Vincent Ko features the...
• 12/04/2013 - Stay stylish this Spring...
• 10/04/2013 - Coming soon...
• 5/04/2013 - Introducing the Jardins...