关于JS级联的问题。为什么能在谷歌浏览器上而不能在IE浏览器上实现?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.<html>
<head>
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script type = "text/javascript">
var provinces = null;
var cities_hn = null;
var cities_hb = null;
var roads_cs = null;
var roads_zz = null;
var selectedProvince = null;
var selectedCity = null;
var selectedRoad = null;
function initVariables(){
try{
//省份
provinces = [ {
name : "湖北",
//cities : cities_hb
}, {
name : "湖南",
//cities : cities_hn
} ];
//湖北的城市
cities_hb=[{
name:"武汉",
roads:[]
},{
name:"宜昌",
roads:[]
}];
//湖南的城市
cities_hn=[{
name : "长沙",
//roads:roads_cs
},{
name : "株洲",
//roads:roads_zz
}];
//长沙的街道
road_cs = [{
name:"黄兴路"
},{
name:"下河街"
},{
name:"宝蓝街"
}];
//株洲的街道
road_zz = [{
name:"株洲1"
},{
name:"株洲2"
},{
name:"株洲3"
}];
}catch(e){
alert(e+":初始化发生错误,请检查后台程序");
}
}
function init(){
initVariables();
initProvincesSel();
}
function initProvincesSel(){
if(provinces && cities_hb && cities_hn && roads_cs && roads_zz){
initVariables();
}
var s1= document.getElementById("s1");
initSelect(s1,"----请选择省份----",0);
addOptions(s1,provinces);
}
function initSelect(sel, text, value){
sel.options.length = 0;
var option =new Option (text);
sel.appendChild(option);
}
function addOptions(target,arr){
if(!(arr instanceof Array)){
return;
}
for(var i = 0; i < arr.length ; i++){
var pointer = arr[i];
var option = new Option(pointer.name);
target.appendChild(option);
}
}
</script>
</head>
<body onload = "init()">
省份:
<select id = "s1">
<option>----请选择省份----</option>
</select>
城市:
<select id = "s2">
<option>----请选择城市----</option>
</select>
街道:
<select id = "s3">
<option>----请选择街道----</option>
</select>
</body>
</html>