ie和火狐兼容问题
1. document.form.item 问题
(1)现有问题:
现有代码中存在许多 document.formName.item("itemName") 这样的语句,不能在Firefox(火狐)下运行
(2)解决方法:
改用 document.formName.elements["elementName"]
2. 集合类对象问题
(1)现有问题:
现有代码中许多集合类对象取用时使用 (),IE 能接受,Firefox(火狐)不能。
(2)解决方法:
改用 [] 作为下标运算。如:
此外,如果新代码中第一行不改,与老代码一样的话(即 gotoSubmit 调用没有给参数),则仍然只能在IE中运行,但不会出错。所以,这种方案 tpl 部分仍与老代码兼容。
<br /><input type="button" name="someButton" value="提交" onclick="javascript:gotoSubmit()"/><br />...<br /><script language="javascript"><br />function gotoSubmit() {<br />...<br />alert(window.event); // use window.event<br />...<br />}<br /></script>
?
document.getElementsByName("inputName")(1) 改为document.getElementsByName("inputName")[1]
document.forms("formName") 改为 document.forms["formName"]。