[英]sort alphabet list blogspot
我有這個腳本:
<script type="text/javascript">
function getposttitle(json) {
// Get total posts
var totalposts = json.feed.openSearch$totalResults.$t;
for (var i = 0; i < totalposts; i++)
{
var posturl;
// Get rel=alternate for truly post url
for (var j=0; j < json.feed.entry[i].link.length; j++)
{
if (json.feed.entry[i].link[j].rel == 'alternate')
{
break;
}
}
var poststitle = json.feed.entry[i].title.$t;
document.write(' '+poststitle+'<br/>');
}
}
</script>
<script type="text/javascript" src="http://BLOGURL.blogspot.com/feeds/posts/default/-/BLOGLABEL?alt=json-in-script&max-results=10000&callback=getposttitle"></script>
現在,我應該更改什么才能將其作為字母列表排序?
以及刪除&max-results = 10000的任何想法,因為如果我刪除它,只會顯示25個結果。
以下是指向API的鏈接: https : //developers.google.com/blogger/docs/2.0/developers_guide_protocol
有兩個與您的問題相關的參數:
max-results:要返回的最大條目數。
orderby:返回條目的順序,例如上次修改(默認),開始時間或更新。
您在哪里:
src="http://BLOGURL.blogspot.com/feeds/posts/default/-/BLOGLABEL?alt=json-in-script&max-results=10000&callback=getposttitle">
更改為此:
src="http://BLOGURL.blogspot.com/feeds/posts/default/-/BLOGLABEL?alt=json-in-script&max-results=10000&orderby=title&callback=getposttitle">
在這里,我選擇標題字段作為排序的字段,而不是默認字段(最后修改的字段)。 您可以將max-results設置為較小的數字,例如100,以減少返回的結果。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.