In HTML pages because of the use of the form, you often need to disable enter to submit the form. Because the content page or the master page itself has type= "submit" button, when the TextBox is focused, pressing ENTER will touch the default submission of the publication (ie or Firefox), so you need to listen to the user's keys in onkeydown. The actual test, IE8 causes the form to submit the uncertainty factor to be too many, clicks the form table the TD to be able to contact the publication form to submit, but the Firefox does not; so in IE and FF to disable form submission requires different ideas.
For IE:
Return true only if the event source is textarea, allow the default action, and all other elements to be answered false to prevent form submission and any responses.
For Firefox:
return false to prevent form default actions only when the event source is input, while the other element is true to allow default actions, such as textarea multiple lines of input.
So the complete code is as follows:[XHTML] View Plain copy <mce:script language= "javascript" type= "Text/javascript" ><!-- //Disable Enter form automatic submission document.onkeydown = function (event) { var target, code, tag; if (!event) { event = window.event; / /For IE browser target = event.srcElement; code = event.keyCode; if (code == 13) { tag = target.tagName; if (tag == "TEXTAREA") { return true; } else { return false; } } } else { target = event.target; //for browsers that follow the standards of the consortium, such as firefox code = event.keyCode; if (code == 13) { tag = target.tagname; if (tag == "INPUT") { return false; } else { return true; } } } }; // --></mce:script> Applying the above JavaScript code to the page where you want to disable the ENTER key to automatically submit the form, the test Ie,firefox and the Chrome browser are perfect for the ENTER key to automatically submit the form issue.