需要使用 javascript 按字母顺序对 rss 提要进行排序。
我得到的只是顶部的“查看职位链接”
调试器给了我这个错误: SCRIPT5007: Unable to get value of the property 'toLowerCase': object is null or undefined
这不起作用:
<script type="text/javascript" src="http://www.google.com/jsapi?key=ABQIAAzOfx2c8w9UU2piCi-QfziRRwcONvftZBEURdgjnJbq9oC0AJ3BRlDevnMejQ1U5ax6a0JLTNKz_k1A"></script>
<style text="text/css">
#positions-wrapper {
font-family: Arial, Helvetica;
font-size: 11px;
}
#positions {
border: 1px solid #eee;
padding: 0px 5px 5px 5px;
margin-top: 5p;x
}
#positions-header {
padding: 0px 5px 5px 5px;
font-weight: bold;
}
#positions a {
color: #4C4C4C;
text-decoration: none;
padding-bottom: 0px;
border-bottom: 1px dotted #888;
}
#positions a:hover {
border-bottom: 1px solid #888;
}
#positions .position-odd {
background-color: #e5e1dc;
}
#positions div {
padding: 5px;
}
</style>
<script type="text/javascript">
google.load("feeds", "1");
google.setOnLoadCallback(initialize);
function initialize() {
var feed = new google.feeds.Feed('http://other.domain.com/rss_feed_clean.aspx');
feed.setNumEntries(100);
feed.load(function(result) {
if (!result.error) {
var container = document.getElementById("feed");
//*** adding sort by title ***
result.feed.entries.sort(function(a, b){
debugger;
var titleA=a.Title.toLowerCase();
titleB=b.Title.toLowerCase();
if (titleA< titleB)
return -1
if (titleA> titleB)
return 1
return 0
})
//*** process sorted array
for (var i = 0; i < result.feed.entries.length; i++) {
var entry = result.feed.entries[i];
var title = entry.title;
var link = entry.link;
jQuery("#positions").append("<div><a href=\"" + link + "\" target=\"_blank\">" + title + "</a></div>");
}
jQuery("#positions div:odd").addClass("position-odd");
}
});
}
</script>
<div id="positions-wrapper">
<div id="positions">
<div id="positions-header"><a href="http://other.domain.com/" target="_blank">View Open Position List</a></div>
</div>
</div>