JS高手,谁能帮帮我。联动菜单失灵
yixiang.xml
<?xml version="1.0" encoding="utf-8" ?>
<yixiang>
<出租>
<XIANG>厂房出租</XIANG>
<XIANG>仓库出租</XIANG>
<XIANG>商铺出租</XIANG>
<XIANG>工业用地出租</XIANG>
</出租>
<出售>
<XIANG>厂房出售</XIANG>
<XIANG>仓库出售</XIANG>
<XIANG>小区厂房出售</XIANG>
<XIANG>土地出售</XIANG>
<XIANG>商铺出售</XIANG>
</出售>
<求租>
<XIANG>求租厂房</XIANG>
<XIANG>求租仓库</XIANG>
<XIANG>求租商铺</XIANG>
<XIANG>求租场地</XIANG>
</求租>
<求购>
<XIANG>求购厂房</XIANG>
<XIANG>求购仓库</XIANG>
<XIANG>求购商铺</XIANG>
<XIANG>求购土地</XIANG>
<XIANG>求购工业用地</XIANG>
</求购>
</yixiang>
infoadd.aspx
<html xmlns="http://www.w3.org/1999/xhtml" >
<script language="javascript" defer>
//通过加载一个外部xml文件,对xml进行操作的
var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
xmlDoc.async = false;
xmlDoc.resolveExternals = false;
xmlDoc.load("yixiang.xml");
if (xmlDoc.parseError.errorCode != 0) {
var myError = xmlDoc.parseError;
alert("You have error " + myErr.reason);
} else {
var root = xmlDoc.documentElement;
for (var i=0; i<root.childNodes.length; i++) {
var oOption1 = document.createElement("option");
oOption1.value = root.childNodes.item(i).baseName;
oOption1.innerText = root.childNodes.item(i).baseName;
document.form1.Txt_Intent.appendChild(oOption1);
}
var currNode = root.childNodes.item(0);
for (var j=0; j<currNode.childNodes.length; j++) {
var oOption2 = document.createElement("option");
oOption2.value = currNode.childNodes.item(j).text;
oOption2.innerText = currNode.childNodes.item(j).text;
document.form1.Txt_Tclass.appendChild(oOption2);
}
}
function sonChange(index){
var root = xmlDoc.documentElement;
var currNode = root.childNodes.item(index);
var counter = document.form1.Txt_Tclass.children.length;
for(var i=0;i<counter;i++){
document.form1.Txt_Tclass.removeChild(document.form1.Txt_Tclass.children[0]);
}
for (var j=0; j<currNode.childNodes.length; j++) {
var oOption2 = document.createElement("option");
oOption2.value = currNode.childNodes.item(j).text;
oOption2.innerText = currNode.childNodes.item(j).text;
document.form1.Txt_Tclass.appendChild(oOption2);
}
}
</script>
<head id="Head1" runat="server">
<title>无标题页</title>
</head>
<body topmargin=0>
<form id="form1" runat="server">
<asp:DropDownList ID="Txt_Intent" runat="server" name="Txt_Intent" onchange="sonChange(this.selectedIndex)" Width="88px">
</asp:DropDownList>
<asp:DropDownList ID="Txt_Tclass" runat="server" name="Txt_Tclass" Width="108px">
</asp:DropDownList>
</form>
</body>
</html>
联动菜单失灵,查看IE角本提示:
错误'document.form1.Txt_Intent'为空或不是对象
JS高手,谁能帮帮我。
------解决方案--------------------
我在IE7和傲游 里面测试正常啊,ff不支持Msxml2的