/*显示微博*/
function show_WeiBo(user_id, num, page, divid) { var xmlResult; $ID(divid).style.visibility = "hidden"; var regxml = AjaxObject(); if (regxml) { regxml.onreadystatechange = function() { if (regxml.readyState == 4) { if (regxml.status == 200) { xmlResult = regxml.responseXML; var results, i, strTemp = "", strPage = "", W_id, UserId, ParentId, Content, Created, PageUrl, FlashUrl, PicUrl, Pic, Type, allrec, totalpage, pages; results = xmlResult.getElementsByTagName("result"); if (results[0].getElementsByTagName("Id")[0].firstChild.data == "#") { strTemp = "<font class=\"gray\"><br /> ---暂无相关信息!---</font>"; } else { allrec = xmlResult.getElementsByTagName("allrec")[0].firstChild.data; totalpage = xmlResult.getElementsByTagName("totalpage")[0].firstChild.data; pages = xmlResult.getElementsByTagName("page")[0].firstChild.data; var currentpage = parseInt(pages); /*分页-start-*/ if (totalpage > 1) { strPage += "<div class=\"page_list\">"; var n = currentpage + 1; var p = currentpage - 1; if (p <= 0) { p = 1; } if (n >= totalpage) { n = totalpage; } var minpage = currentpage - 3; var maxpage = currentpage + 3; if (minpage <= 0) { minpage = 1; maxpage = 7; } if (maxpage > totalpage) { maxpage = totalpage; minpage = maxpage - 6; if (minpage <= 0) { minpage = 1; } } /*第一页和上一页*/ if (currentpage != 1) { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + "," + p + ",'" + divid + "');\">上一页</a>"; } else { strPage += "<span class=\"page1\">上一页</span>"; } if (currentpage - 1 > 3 && totalpage > 7) { if (currentpage - 1 == 4 || totalpage == 8) { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + ",1,'" + divid + "');\">1</a>"; } else { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + ",1,'" + divid + "');\">1</a><span>.</span>"; } } /*第一页和上一页*/ for (var i = minpage; i <= maxpage; i++) { if (currentpage == i) { strPage += "<a class=\"page1\">" + i + "</a>"; } else { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + "," + i + ",'" + divid + "');\">" + i + "</a>"; } } /*最后一页和下一页*/ if (totalpage - currentpage > 3 && totalpage > 7) { if (totalpage - currentpage == 4 || totalpage == 8) { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + "," + totalpage + ",'" + divid + "');\">" + totalpage + "</a>"; } else { strPage += "<span>.</span><a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + "," + totalpage + ",'" + divid + "');\">" + totalpage + "</a>"; } } if (currentpage < totalpage) { strPage += "<a href=\"javascript:\" οnclick=\"javascript:show_WeiBo(" + user_id + "," + num + "," + n + ",'" + divid + "');\" >下一页</a>"; } else { strPage += "<span class=\"page1\">下一页</span>"; } /*最后一页和下一页*/ strPage = strPage + "</div>"; $ID(divid + "_b_page").innerHTML = strPage; /*分页-end-*/ } for (i = 0; i < results.length; i++) { strTemp += "<ul class=\"weibo_list\" οnmοuseοver=\"\" οnmοuseοut=\"\">"; W_id = results[i].getElementsByTagName("Id")[0].firstChild.data; UserId = results[i].getElementsByTagName("UserId")[0].firstChild.data; ParentId = results[i].getElementsByTagName("ParentId")[0].firstChild.data; Content = unescape(results[i].getElementsByTagName("Content")[0].firstChild.data); Created = unescape(results[i].getElementsByTagName("Created")[0].firstChild.data); PageUrl = unescape(results[i].getElementsByTagName("PageUrl")[0].firstChild.data); FlashUrl = unescape(results[i].getElementsByTagName("FlashUrl")[0].firstChild.data); PicUrl = unescape(results[i].getElementsByTagName("PicUrl")[0].firstChild.data); Pic = unescape(results[i].getElementsByTagName("Pic")[0].firstChild.data); Type = results[i].getElementsByTagName("Type")[0].firstChild.data; strTemp += "<li>"+Content+" "+Created+"</li>"; strTemp += "</ul>"; } } $ID(divid).innerHTML = strTemp; $ID(divid).style.visibility = ""; } } } regxml.open("GET", "Ajax/Handler.ashx?user_id=" + user_id + "&pageSize=" + num + "&page=" + page, true); regxml.send(null); }}调用页面:<div class="content" id="weibo_list">
</div><script language="javascript" type="text/javascript">
show_WeiBo(0,5,1,'weibo_list');</script>