最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于JQuery的抓取博客園首頁RSS的代碼

 更新時(shí)間:2011年12月01日 23:00:20   作者:  
JQuery 抓取博客園首頁RSS直接將代碼保存到文本文檔,更改后綴名為html瀏覽 即可查看效果
效果圖:

實(shí)現(xiàn)代碼:
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
</head>
<body>
<table id='tbl1' cellpadding="1" cellspacing="1" bgcolor="#333333" width="800px" style="line-height:30px;">
<tr bgcolor="#FFFFFF"><td align="center" width="70%">標(biāo)題</td><td align="center" width="30%">時(shí)間</td></tr>
</table>
<div id="loading" style="display:none"><font color='red'>正在加載數(shù)據(jù)。。。</font></div>
</body>
</html>
<script language="javascript" type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script language="javascript" type="text/javascript" >
$(function(){
var html="";
var bgcolor="";
$.ajax({
url:"http://www.cnblogs.com/rss",
type:"get",
//dataType:($.browser.msie) ? "text" : "xml",
success:function(data){
$("item",data).each(function(index,element){
bgcolor=index%2==0 ?" bgcolor='#F1F1F1' ":" bgcolor='#FFFFFF' ";
html+="<tr "+bgcolor+"><td><a href='"+$(this).find("link").text()+"'>"+FormatContent($(this).find("title").text(),40)+"</td><td>"+ new Date($(this).find("pubDate").text()).format("yyyy-MM-dd hh:mm:ss");+"</td></tr>";
});
$("#tbl1 tr:not(':first')").remove();//移除非第一行
$("#tbl1").append(html);//綁定數(shù)據(jù)到table
},
complete:function(){
$("#loading").hide();
},
beforeSend:function(x){
//x.setRequestHeader("Content-Type", "charset=utf-8");
$("#loading").show();
},
error:function(){
alert("error");
}
});
});
</script>
<script language="javascript">
/**
* 時(shí)間對象的格式化;
*/
Date.prototype.format = function(format) {
/*
* eg:format="YYYY-MM-dd hh:mm:ss";
*/
var o = {
"M+" :this.getMonth() + 1, // month
"d+" :this.getDate(), // day
"h+" :this.getHours(), // hour
"m+" :this.getMinutes(), // minute
"s+" :this.getSeconds(), // second
"q+" :Math.floor((this.getMonth() + 3) / 3), // quarter
"S" :this.getMilliseconds()
// millisecond
}
if (/(y+)/.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + "")
.substr(4 - RegExp.$1.length));
}
for ( var k in o) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k]
: ("00" + o[k]).substr(("" + o[k]).length));
}
}
return format;
}
//格式化標(biāo)題信息
function FormatContent(word,length){
return word.length>length?word.substring(0,length)+"...":word;
}
</script>

相關(guān)文章

最新評論

波密县| 婺源县| 湖北省| 瑞金市| 江安县| 绥芬河市| 即墨市| 吉首市| 那曲县| 奈曼旗| 抚远县| 灵丘县| 三都| 玉环县| 绥中县| 扎赉特旗| 张家川| 盱眙县| 宣威市| 英超| 虎林市| 金阳县| 永定县| 桃园县| 文安县| 韶关市| 社旗县| 新沂市| 香格里拉县| 竹溪县| 互助| 莱州市| 格尔木市| 马鞍山市| 毕节市| 德昌县| 湖州市| 兴安盟| 沙雅县| 秦皇岛市| 株洲县|