<html>
<head>
<title>javascript读取RSS数据</title>
<META content="text/html; charset=utf-8" http-equiv=Content-Type />
</head>
<body leftmargin="0" topmargin="0" onload=aaa()>
<font><h3 align="center">javascript读取RSS数据</h3></font>
<br>
<div id="container" >News Loading...</div>
<script language="JavaScript1.2">
function aaa(){
if (window.ActiveXObject)
{
//document.write("Microsoft.XMLDOM");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation && document.implementation.createDocument)
{
//document.write("document.implementation.createDocument");
var xmlDoc= document.implementation.createDocument("","doc",null);
}
if (typeof xmlDoc!="undefined")
{
var xmlsource="http://rss.xinhuanet.com/rss/it.xml";
//document.write(tickercontainer)
xmlDoc.load(xmlsource)
//alert(xmlDoc);
fetchxml();
xmlDoc.onload=output;
}
}function fetchxml()
{
if (xmlDoc.readyState==4)
//document.write("fdfdf");
output();
else
setTimeout("fetchxml()",10);
}
function output()
{ var root;
var title;
var link;
var items;
var item;
var temp="";
root = xmlDoc.getElementsByTagName("channel")[0];
title =root.getElementsByTagName("title")[0];
//temp = title.firstChild.nodeValue +"<br>";
items=root.getElementsByTagName("item");
for(i=0;i<=items.length-1;i++)
{
item=items[i];
title=item.getElementsByTagName("title")[0];
link=item.getElementsByTagName("link")[0];
//alert(link.firstChild.nodeValue);
temp = temp + "<font size=-1><a href=" + link.firstChild.nodeValue+ " target='_bank'>" +title.firstChild.nodeValue+"<br>"+"</a></font>";
//temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>";
document.getElementById("container").innerHTML = temp;
//alert(link.firstChild.nodeValue);
//test(link.firstChild.nodeValue);
}
//setTimeout(output(),1000)
}
</script>
</body>
</html>
<head>
<title>javascript读取RSS数据</title>
<META content="text/html; charset=utf-8" http-equiv=Content-Type />
</head>
<body leftmargin="0" topmargin="0" onload=aaa()>
<font><h3 align="center">javascript读取RSS数据</h3></font>
<br>
<div id="container" >News Loading...</div>
<script language="JavaScript1.2">
function aaa(){
if (window.ActiveXObject)
{
//document.write("Microsoft.XMLDOM");
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation && document.implementation.createDocument)
{
//document.write("document.implementation.createDocument");
var xmlDoc= document.implementation.createDocument("","doc",null);
}
if (typeof xmlDoc!="undefined")
{
var xmlsource="http://rss.xinhuanet.com/rss/it.xml";
//document.write(tickercontainer)
xmlDoc.load(xmlsource)
//alert(xmlDoc);
fetchxml();
xmlDoc.onload=output;
}
}function fetchxml()
{
if (xmlDoc.readyState==4)
//document.write("fdfdf");
output();
else
setTimeout("fetchxml()",10);
}
function output()
{ var root;
var title;
var link;
var items;
var item;
var temp="";
root = xmlDoc.getElementsByTagName("channel")[0];
title =root.getElementsByTagName("title")[0];
//temp = title.firstChild.nodeValue +"<br>";
items=root.getElementsByTagName("item");
for(i=0;i<=items.length-1;i++)
{
item=items[i];
title=item.getElementsByTagName("title")[0];
link=item.getElementsByTagName("link")[0];
//alert(link.firstChild.nodeValue);
temp = temp + "<font size=-1><a href=" + link.firstChild.nodeValue+ " target='_bank'>" +title.firstChild.nodeValue+"<br>"+"</a></font>";
//temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>";
document.getElementById("container").innerHTML = temp;
//alert(link.firstChild.nodeValue);
//test(link.firstChild.nodeValue);
}
//setTimeout(output(),1000)
}
</script>
</body>
</html>
解决方案 »
- 关于JS实现的可拖动DIV只兼容IE,其他浏览器不兼容的问题
- 如何让弹出的iframe层完全透明,可以显示被遮盖的内容
- 紧急求救。。。。JS带参数回传无法调用父页面方法..................................
- utf-8文件没设定utf-8问题
- 怎么实现javascript的队列,数据结构的。
- javascript如何捕捉下层的图形?
- 求一个时间的算法
- 请问何处有《VML中文教程》
- 如何控制IE的工具栏按扭和菜单????
- jqgrid增加、编辑和删除问题
- 为什么这种方法不能给表格单元格赋值
- 请问如何在一个function中调用另外一个function中定义产生的数组???
报什么错撒?
是不是变量未定义?
<html>
<head>
<title>javascript读取RSS数据</title>
<META content="text/html; charset=utf-8" http-equiv=Content-Type />
</head>
<body leftmargin="0" topmargin="0" onload=on_load()>
<font><h3 align="center">javascript读取RSS数据</h3></font>
<br/>
<div id="container" >News Loading...</div>
<script language="JavaScript1.2">
var xmlDoc;
function on_load(){
if (window.ActiveXObject){
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
}else if (document.implementation && document.implementation.createDocument){
xmlDoc= document.implementation.createDocument("","doc",null);
}
if(typeof xmlDoc!="undefined"){
var xmlsource="http://rss.xinhuanet.com/rss/it.xml";
xmlDoc.async="false";
xmlDoc.load(xmlsource)
fetchxml();
}
}function fetchxml(){
if (xmlDoc.readyState==4)
output();
else
setTimeout("fetchxml()",10);
}
function output(){
var root;
var title;
var link;
var items;
var item;
var temp="";
root = xmlDoc.getElementsByTagName("channel")[0];
title =root.getElementsByTagName("title")[0];
items=root.getElementsByTagName("item");
for(i=0;i<=items.length-1;i++){
item=items[i];
title=item.getElementsByTagName("title")[0];
link=item.getElementsByTagName("link")[0];
temp = temp + "<font size=-1><a href=" + link.firstChild.nodeValue+ " target='_bank'>" +title.firstChild.nodeValue+"<br/>"+"</a></font>";
document.getElementById("container").innerHTML = temp;
}
}
</script>
</body>
</html>
HTML的代码是从上到下顺序执行的.你放到下面在页面加载的时候会报错的.