请问:一个JSP页面中如何调用多个RSS源(导入JS写的XMLHTTP每次只能读1个RSS) 本帖最后由 zzheaven 于 2012-03-22 22:15:56 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我需要多次调用不同新闻源的RSS(XML)来完成。 //Container for ticker. Modify its STYLE attribute to customize style:var tickercontainer=''var xmlsource="http://rss.sina.com.cn/news/marquee/ddt.xml";//var xmlsource="http://news.baidu.com/n?cmd=1&class=enternews&tn=rss";var root;var title;var link; var items;var item;var images;var image;var description;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"){ //document.write(tickercontainer) //xmlDoc.async=true; xmlDoc.load(xmlsource)//加载xml文件(xml的地址)} function fetchxml(){ if (xmlDoc.readyState==4) //状态为4时候才执行 output() else setTimeout("fetchxml()",2000)}function output(){ 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++) for(i=0;i<=11;i++) { item=items[i]; title=item.getElementsByTagName("title")[0]; link=item.getElementsByTagName("link")[0]; description=item.getElementsByTagName("description")[0]; temp = temp + "<font size=-1><a href=" + link.firstChild.nodeValue+ " target='_bank'>" + title.firstChild.nodeValue +"</a></font><br><br>"; //temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>"; document.getElementById("container").innerHTML = temp; } }if (window.ActiveXObject) { fetchxml() }else if (typeof xmlDoc!="undefined"){ alert("sth is wrong!")} 这个是JS代码,需要从页面中调用 就仅仅写了上面的JS代码,然后在htm页面中调用,有问题吗? 一个页面通过多次调用这个js文件,然后只修改url(xmlsource)可以将内容都显示吗?怎么没有大牛回答,俺是菜鸟 dhtmlXWindows的使用 急,请问javascript对象模型的问题? 求救一个JS效果 如何删除嵌套的html元素 (MzTreeView)控件使用的小问题 2 questions.如何让一个包含框架的网页在打开时自动最大化;如何关闭父窗口? 简单问题:在网页中如何隐藏鼠标?谢谢了! 困扰我的问题!dream制作导航条下拉菜单问题!相信好多人都遇到过。 <PARAM NAME="Command" VALUE="Close">出问题 新手jsp遇到情况了 求大虾帮忙 js获取当前月份 js中能获取变量的地址吗
//Container for ticker. Modify its STYLE attribute to customize style:
var tickercontainer=''var xmlsource="http://rss.sina.com.cn/news/marquee/ddt.xml";
//var xmlsource="http://news.baidu.com/n?cmd=1&class=enternews&tn=rss";
var root;
var title;
var link;
var items;
var item;
var images;
var image;
var description;
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")
{
//document.write(tickercontainer)
//xmlDoc.async=true;
xmlDoc.load(xmlsource)//加载xml文件(xml的地址)
}
function fetchxml()
{
if (xmlDoc.readyState==4) //状态为4时候才执行
output()
else
setTimeout("fetchxml()",2000)
}
function output()
{
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++)
for(i=0;i<=11;i++)
{
item=items[i];
title=item.getElementsByTagName("title")[0];
link=item.getElementsByTagName("link")[0];
description=item.getElementsByTagName("description")[0];
temp = temp + "<font size=-1><a href=" + link.firstChild.nodeValue+ " target='_bank'>" + title.firstChild.nodeValue +"</a></font><br><br>";
//temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>";
document.getElementById("container").innerHTML = temp;
}
}
if (window.ActiveXObject)
{
fetchxml()
}
else if (typeof xmlDoc!="undefined")
{
alert("sth is wrong!")
}
这个是JS代码,需要从页面中调用