六月下雨了,天又下了雨。我已经很久没有见过如此下雨了,柔软而缠绵,就像你的眼睛,轻轻地刷着我寂寞的肩膀。闻一闻书本,站在窗前,对朋友说:早上好!
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<htmlxmlns="http://www.w3.org/1999/xhtml">
<head>
<title>thisistest</title>
<scripttype="text/javascript">
varxmlHttp;
functioncreateXMLHttpRequest(){
if(window.ActiveXObject){
xmlHttp=newActiveXObject("Microsoft.XMLHTTP");
}
elseif(window.XMLHttpRequest){
xmlHttp=newXMLHttpRequest();
}
}
functionreadRSS(url){
createXMLHttpRequest();
xmlHttp.onreadystatechange=handleStateChange;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}
functionhandleStateChange(){
if(xmlHttp.readyState==4){
if(xmlHttp.status==200){
ResultSet();
}
}
}
functionResultSet(){
varresults=xmlHttp.responseXML;
vartitle=null;
varitem=null;
varlink=null;
varauthor=null;
varpubDate=null;
vardescription=null;
//得到channel
varccc=results.getElementsByTagName("channel");
varheadtitle=ccc[0].getElementsByTagName("title")[0].firstChild.nodeValue;
varheadlink=ccc[0].getElementsByTagName("link")[0].firstChild.nodeValue;
varcell=document.createElement("div");
cell.innerHTML="<h1><arel="nofollow noopener noreferrer" href="+headlink+"target=_blank>"+headtitle+"</a></h1><br>";
document.getElementById("result").appendChild(cell);
//得到items
varitems=results.getElementsByTagName("item");
for(vari=0;i<items.length;i++){
item=items[i];
link=item.getElementsByTagName("link")[0].firstChild.nodeValue;
title=item.getElementsByTagName("title")[0].firstChild.nodeValue;
author=item.getElementsByTagName("author")[0].firstChild.nodeValue;
pubDate=item.getElementsByTagName("pubDate")[0].firstChild.nodeValue;
//description=item.getElementsByTagName("description")[0].firstChild.nodeValue;
varcell=document.createElement("div");
cell.innerHTML="<arel="nofollow noopener noreferrer" href="+link+"target=_blank>"+title+"</a><fontcolor=red>   作者:</font>"+author+"<br>";
document.getElementById("result").appendChild(cell);
//varcell1=document.createElement("div");
//cell1.innerHTML=description;
//document.getElementById("result").appendChild(cell1);
}
}
functionreadrss1()
{
varurl=document.getElementById("txturl").value;
if(url=="")
{
alert("请输入RSS地址");
}
else
{
readRSS(url);
}
}
vari=1;
varj=0;
functionread()
{
if(j==0)
{
readBlogjava();
window.setTimeout("testRead()",100);
}
}
functiontestRead()
{
window.setTimeout("read()",1000);
}
functionreadBlogjava()
{
switch(i)
{
case(1):
i++;
readRSS("http://www.blogjava.net/rss.aspx");
break;
case(2):
i++;
readRSS(http://beginner.blogjava.net/rss.aspx);
break;
case(3):
i++;
readRSS(http://general.blogjava.net/rss.aspx);
break;
case(4):
i++;
readRSS(http://life.blogjava.net/rss.aspx);
break;
//博客园的
case(5):
i++;
readRSS(http://www.cnblogs.com/rss.aspx);
break;
case(6):
i++;
readRSS(http://beginner.cnblogs.com/rss.aspx);
break;
case(7):
i++;
readRSS(http://life.cnblogs.com/rss.aspx);
break;
case(8):
i++;
readRSS(http://misc.cnblogs.com/rss.aspx);
break;
case(9):
i++;
readRSS(http://cio.cnblogs.com/rss.aspx);
break;
case(10):
i++;
readRSS(http://news.cnblogs.com/rss.aspx);
break;
case(11):
i++;
readRSS(http://bookreview.cnblogs.com/rss.aspx);
break;
case(12):
i++;
readRSS(http://job.cnblogs.com/rss.aspx);
break;
case(13):
i++;
readRSS(http://gis.cnblogs.com/rss.aspx);
break;
case(14):
i++;
readRSS(http://clubs.cnblogs.com/rss.aspx);
break;
case(15):
i++;
readRSS(http://software.cnblogs.com/rss.aspx);
break;
default:
alert("加载完毕!");
i++;
j++;
break;
}
}
</script>
</head>
<bodyonload=testRead()>
<h1>ajax读rss示例</h1>
<form>
输入一个RSS地址:<inputtype="text"value="http://www.blogjava.net/wujun/rss.aspx"size=50id="txturl">
<inputtype="button"value="查看"onclick="readrss1()">
<inputtype="button"onclick="hideobject()"value="test">
</form>
<divid="result"></div>
<EMBEDstyle="POSITION:absolute;top:1px;left:1px;"align=right
src=http://www.nice.or.jp/~mosmos/free/f105.swfwidth=200height=200
type=application/x-shockwave-flash;quality="high"wmode="transparent"></EMBED>
</body>
</html> 到此这篇关于用ajax自动加载blogjava和博客园的rss就介绍到这了。最可怕的敌人,就是没有坚定的信念。更多相关用ajax自动加载blogjava和博客园的rss内容请查看相关栏目,小编编辑不易,再次感谢大家的支持!