發現沒有用<Form>標籤和form.submit方法的斷行符號提交在firefox下面不工作,因為FireFox不捕捉斷行符號事件。一般在IE下實現斷行符號可以這樣:
<INPUT TYPE=text NAME="hanbai_cd" SIZE=20 maxlength = 8 onkeydown=KeyDown()>
1: function KeyDown()
2: {
3: if (event.keyCode == 13)
4: {
5: event.returnValue=false;
6: event.cancel = true;
7: Form1.btnsubmit.click();
8: }
9: }
上面只針對IE, 在firefox下面不工作,因為FireFox不捕捉斷行符號事件,FF和IE相容代碼如下:
1: <script type="text/javascript">
2: <!--
3:
4: if(document.addEventListener){//如果是Firefox
5: document.addEventListener("keypress",fireFoxHandler, true);
6: }else{
7: document.attachEvent("onkeypress",ieHandler);
8: }
9:
10: function fireFoxHandler(evt){
11: //alert("firefox");
12: if(evt.keyCode==13){
13: validateLogon();//你的代碼
14: }
15: }
16:
17: function ieHandler(evt){
18: //alert("IE");
19: if(evt.keyCode==13){
20: validateLogon();//你的代碼
21: }
22: }
23:
24: //-->
25: </script>