火狐不能识别JS代码,求修改。

[复制链接]
查看11 | 回复2 | 2010-8-1 13:30:53 | 显示全部楼层 |阅读模式
function getCity(currProvince)
{
//当前 所选择 的 省
var i,j,k;
//清空 城市 下拉选单
document.all.selCity.length = 0;
for (i = 0 ;i < cityArray.length;i++)
{
//得到 当前省 在 城市数组中的位置
if(cityArray[0] == currProvince)
{
//得到 当前省 所辖制的 地市
tmpcityArray = cityArray[1].split("|");
for(j = 0; j < tmpcityArray.length; j++)
{

//填充 城市 下拉选单

document.all.selCity.options[document.all.selCity.length] = new Option(tmpcityArray[j], tmpcityArray[j]);
}
}
}
}
以上JS代码IE可以正常运行,火狐不可以,谁能帮忙修改一下。

回复

使用道具 举报

千问 | 2010-8-1 13:30:53 | 显示全部楼层
docume.all在Firefox中不支持解决 firefox 不支持 document.all的方法今天为Kinoko-World写v2版,遇到了点js的小问题。document.all在firefox下不支持,上网搜索了一下, 用 document.getElementsByTagName("*") 替代就OK了。 getElementsByTagName("*") 可以得到得到所有元素的集合 getElemntById 可以按id得到某一元素 getElementsByName 可以得到按name属性得到某一元素 getElementById效果更好啊
回复

使用道具 举报

千问 | 2010-8-1 13:30:53 | 显示全部楼层
火狐不认 “document.all”这种东西,你可以这样写:document.getElementById("selCity").length=0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行