第一个JS文件
<script language="JavaScript1.2">
var xmlsource="test.xml";
var root;
var title;
var link;
var items;
var item;
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.load(xmlsource)
//alert(xmlDoc);
}
function fetchxml()
{
if (xmlDoc.readyState==4)
//document.write("fdfdf");
output();
else
setTimeout("fetchxml()",10);
}
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++)
{
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)
}
if (window.ActiveXObject){
fetchxml();
}
else if (typeof xmlDoc!="undefined"){
xmlDoc.onload=output;}
function test(a){
}
</script>
第二个文件
<script language="JavaScript1.2">
var xm="http://rss.xinhuanet.com/rss/it.xml";
var ro;
var ti;
var li;
var its;
var it;
var de;
if (window.ActiveXObject)
{
//document.write("Microsoft.XMLDOM");
var Doc = new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation && document.implementation.createDocument)
{
//document.write("document.implementation.createDocument");
var Doc= document.implementation.createDocument("","doc",null);
}
if (typeof Doc!="undefined")
{
//document.write(tickercontainer)
Doc.load(xm)
}
function fe()
{
if (Doc.readyState==4){
ou();}
else{
setTimeout("fe()",10);}
}
function ou()
{
var te="";
ro = Doc.getElementsByTagName("channel")[0];
ti =ro.getElementsByTagName("title")[0];
//temp = title.firstChild.nodeValue +"<br>";
its=ro.getElementsByTagName("item");
alert(its);
for(i=0;i<=its.length-1;i++) {
it=its[i];
ti=it.getElementsByTagName("title")[0];
li=it.getElementsByTagName("link")[0];
de=it.getElementsByTagName("description")[0];
//alert(description);
ca=it.getElementsByTagName("category")[0];
pu=it.getElementsByTagName("pubDate")[0];
te = te + "<font size=-1><a href=" + li.firstChild.nodeValue+ " target='_bank'>" +ti.firstChild.nodeValue+"<br>"+ca.firstChild.nodeValue+pu.firstChild.nodeValue+"</a></font><br><br>";
//temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>";
document.getElementById("container0").innerHTML = te;
}
}
if (window.ActiveXObject)
fe()
else if (typeof Doc!="undefined")
Doc.onload=ou
</script>
能不能把第一个JS文件里面得到的地址值传给第二JS文件的xm(地址变量)..
<script language="JavaScript1.2">
var xmlsource="test.xml";
var root;
var title;
var link;
var items;
var item;
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.load(xmlsource)
//alert(xmlDoc);
}
function fetchxml()
{
if (xmlDoc.readyState==4)
//document.write("fdfdf");
output();
else
setTimeout("fetchxml()",10);
}
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++)
{
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)
}
if (window.ActiveXObject){
fetchxml();
}
else if (typeof xmlDoc!="undefined"){
xmlDoc.onload=output;}
function test(a){
}
</script>
第二个文件
<script language="JavaScript1.2">
var xm="http://rss.xinhuanet.com/rss/it.xml";
var ro;
var ti;
var li;
var its;
var it;
var de;
if (window.ActiveXObject)
{
//document.write("Microsoft.XMLDOM");
var Doc = new ActiveXObject("Microsoft.XMLDOM");
}
else if (document.implementation && document.implementation.createDocument)
{
//document.write("document.implementation.createDocument");
var Doc= document.implementation.createDocument("","doc",null);
}
if (typeof Doc!="undefined")
{
//document.write(tickercontainer)
Doc.load(xm)
}
function fe()
{
if (Doc.readyState==4){
ou();}
else{
setTimeout("fe()",10);}
}
function ou()
{
var te="";
ro = Doc.getElementsByTagName("channel")[0];
ti =ro.getElementsByTagName("title")[0];
//temp = title.firstChild.nodeValue +"<br>";
its=ro.getElementsByTagName("item");
alert(its);
for(i=0;i<=its.length-1;i++) {
it=its[i];
ti=it.getElementsByTagName("title")[0];
li=it.getElementsByTagName("link")[0];
de=it.getElementsByTagName("description")[0];
//alert(description);
ca=it.getElementsByTagName("category")[0];
pu=it.getElementsByTagName("pubDate")[0];
te = te + "<font size=-1><a href=" + li.firstChild.nodeValue+ " target='_bank'>" +ti.firstChild.nodeValue+"<br>"+ca.firstChild.nodeValue+pu.firstChild.nodeValue+"</a></font><br><br>";
//temp = temp +"<font size=-1>" + description.firstChild.nodeValue + "</font><br><br>";
document.getElementById("container0").innerHTML = te;
}
}
if (window.ActiveXObject)
fe()
else if (typeof Doc!="undefined")
Doc.onload=ou
</script>
能不能把第一个JS文件里面得到的地址值传给第二JS文件的xm(地址变量)..
解决方案 »
- jquery autocomplete动态传参的问题
- 求救...jsp:索创B/S用户管理系统
- 得到一个div下 特定ID的所有标签。。。
- js 里用Hashtable时的问题
- 关于window.event.returnValue的问题~
- 100分求解决,一个关于动态Menu的WebPart 问题, 涉及到Javascript, CSS
- 帮忙看看这段sript是如何运行的,最好作出解析谢谢!
- 请问csdn导航栏调整宽度时的透明网格条是怎么做的?
- 高分求救:在同一窗口中如何自动转到另一个网页,不用点击连接
- 关于js的问题,这个真的很费解
- title属性实现换行,在firefox中不行,好像得写一个js的title类怎么做啊??
- js查找一字符重复出现的次数.
也就是说把第一个JS文件里面得到的地址值赋值给全局变量
然后第二JS文件的xm(地址变量)的值到全局变量中取