简单的rss阅读器

这是基于ajax的简单的rss读取程序,有基于web的无刷新特点
None.gif <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
None.gif  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"
>
None.gif
< html  xmlns ="http://www.w3.org/1999/xhtml" >
None.gif
< head >
None.gif
< title > RSS Reader </ title >
ExpandedBlockStart.gifContractedBlock.gif
< script  type ="text/javascript" > dot.gif
InBlock.gif
var xmlHttp;
ExpandedSubBlockStart.gifContractedSubBlock.gif
function showRSS()dot.gif{
InBlock.gif
var target=document.getElementById("targeturl");
InBlock.gifreadRSS(target.value);
ExpandedSubBlockEnd.gif}

InBlock.gif
function createXMLHttpReques()
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif   
if(window.ActiiveXObject)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif   xmlHttp
=new ActiveXObject("Microsoft.XMLHttp");
InBlock.gif
else if(window.XMLHttpRequest)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif  xmlHttp
=new XMLHttpRequest();
ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

ExpandedSubBlockEnd.gif}

InBlock.gif
function readRSS(url)
ExpandedSubBlockStart.gifContractedSubBlock.gif
dot.gif{
InBlock.gif  createXMLHttpRequest();
InBlock.gif  xmlHttp.onreadystatechange
=handleStateChange;
InBlock.gif  xmlHttp.open(
"GET",url,true);
InBlock.gif  xmlHttp.send(
null);
ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
function handleStateChange() dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif    
if(xmlHttp.readyState == 4dot.gif{
ExpandedSubBlockStart.gifContractedSubBlock.gif        
if(xmlHttp.status == 200dot.gif{
InBlock.gif            clearPreviousResults();
InBlock.gif            parseResults();
ExpandedSubBlockEnd.gif        }

ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
function clearPreviousResults() dot.gif{
InBlock.gif    
var ListBody = document.getElementById("resultsTitle");
ExpandedSubBlockStart.gifContractedSubBlock.gif    
while(ListBody.childNodes.length > 0dot.gif{
InBlock.gif        ListBody.removeChild(ListBody.childNodes[
0]);
ExpandedSubBlockEnd.gif    }

ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function parseResults() dot.gif{
InBlock.gif    
var results = xmlHttp.responseXML;
InBlock.gif    
var title = null;
InBlock.gif    
var content=null;
InBlock.gif    
var item = null;
InBlock.gif
InBlock.gif    
var items = results.getElementsByTagName("item");
ExpandedSubBlockStart.gifContractedSubBlock.gif    
for(var i = 0; i < items.length; i++dot.gif{
InBlock.gif        item 
= items[i];
InBlock.gif        title 
= item.getElementsByTagName("title")[0].firstChild.nodeValue;
InBlock.gif        content
=item.getElementsByTagName("description")[0].firstChild.nodeValue;
InBlock.gif        addListRow(title,content);
InBlock.gif        
ExpandedSubBlockEnd.gif    }

InBlock.gif
ExpandedSubBlockEnd.gif}

InBlock.gif
InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function addListRow(title,content) dot.gif{
InBlock.gif    
var row = document.createElement("ul");
InBlock.gif    
var cell = createCellWithText(title);
InBlock.gif    
var contentcell=createCellWithContent(content);
InBlock.gif    row.appendChild(cell);
InBlock.gif    row.appendChild(contentcell);
InBlock.gif    
InBlock.gif    document.getElementById(
"resultsTitle").appendChild(row);
ExpandedSubBlockEnd.gif}

InBlock.gif
ExpandedSubBlockStart.gifContractedSubBlock.gif
function createCellWithText(text) dot.gif{
InBlock.gif    
var cell = document.createElement("li");
InBlock.gif    
var textNode = document.createTextNode(text);
InBlock.gif    
InBlock.gif    cell.appendChild(textNode);
InBlock.gif    
InBlock.gif    
return cell;
ExpandedSubBlockEnd.gif}

ExpandedSubBlockStart.gifContractedSubBlock.gif
function createCellWithContent(content) dot.gif{
InBlock.gif
var cell=document.createElement("h1")
InBlock.gif 
var textNode = document.createTextNode(content);
InBlock.gif    
InBlock.gif    cell.appendChild(textNode);
InBlock.gif    
InBlock.gif    
return cell;
ExpandedSubBlockEnd.gif}

ExpandedBlockEnd.gif
None.gif
</ script >
None.gif
</ head >
None.gif
None.gif
< body >
None.gif  
< h2 > Blog文章列表 </ h2 >
None.gif   
< input  type ="text"  id ="targeturl"  name ="textfield"   />
None.gif    
< input  type ="button"  value ="搜索"  onclick ="ShowRSS();" />     
None.gif    
< div  id ="resultsTitle" >
None.gif    
</ div >
None.gif
</ body >
None.gif
</ html >

转载于:https://www.cnblogs.com/abob/archive/2006/08/20/481622.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值