很奇怪的JS问题
为何在自己电脑上测试运行的好好的,一放到外网正式环境这段JS就不行了。提示说第7行缺少对象?什么原因。。
html测试文件内容如下:
<div>
<h2> <span> 活跃用户榜 </span> </h2>
<ul>
<script type= "text/javascript " src= "http://www.nettwn.com/js/hotuser.js "> </script>
</ul>
</div>
hotuser.js 文件如下
var xmlDoc=new ActiveXObject( "Msxml2.DOMDocument ");
xmlDoc.async=false;
xmlDoc.load( "user.xml ");
root=xmlDoc.documentElement;
var nodeNum = root.childNodes.length;
for (i=0;i <nodeNum;i++)
{
node = root.childNodes(i);
var nickname;
var linkurl;
var jf;
var dj;
for (j=0;j <node.childNodes.length;j++)
{
if (node.childNodes(j).nodeName == "nickname ") {nickname = node.childNodes(j).text}
if (node.childNodes(j).nodeName == "linkurl ") {linkurl = node.childNodes(j).text}
if (node.childNodes(j).nodeName == "jf ") {jf = node.childNodes(j).text}
if (node.childNodes(j).nodeName == "dj ") {dj = node.childNodes(j).text}
}
str = " <li> <a href= " + linkurl + " target=_blank> ";
str = str + nickname + " </a> 积分: " + jf + " 等级: " + dj + " <li> ";
document.write(str);
}
------解决方案--------------------呵呵,搂主真晕!
xmlDoc.load( "user.xml ");
改为:
xmlDoc.load( "http://www.nettwn.com/js/user.xml ");