以下以 IE 代替 Internet Explorer,以 MF 代替 Mozzila Firefox
<input type="button" name="someButton" value="提交" onclick="javascript:gotoSubmit()"/>
...
<script language="javascript">
function gotoSubmit() {
...
alert(window.event); // use window.event
...
}
</script>
新代码(可在 IE 和 MF 中运行):
<input type="button" name="someButton" value="提交" onclick="javascript:gotoSubmit(event)"/>
...
<script language="javascript">
function gotoSubmit(evt) {
evt = evt ? evt : (window.event ? window.event : null);
...
alert(evt); // use evt
...
}
</script>
此外,如果新代码中第一行不改,与老代码一样的话(即 gotoSubmit 调用没有给参数),则仍然只能在IE中运行,但不会出错。所以,这种方案 tpl 部分仍与老代码兼容。
<form>
<table>
<input/>
</table>
</form>
MF 中 input.parentNode 的值为 form, 而 IE 中 input.parentNode 的值为空节点var url = 'xx.jsp?objectName=xx&objectEvent=xxx';
frm.action = url;
那么很有可能 url 不会被正常显示以至于参数没有正确的传到服务器var o = e.srcElement || e.target;