按鈕接受回車事件的三種實現方法
阿新 • • 發佈:2019-01-14
方法一:
<script type="text/javascript" event="onkeydown" for="document">
if(event.keyCode==13)
{
var button=document.all("<%=ButtonAddorUpdate.ClientID %>");
button.focus();
button.click();
}
</script>
方法二:
<input type="button" onclick="noClick()" style="margin-top:-1024px;" id="noUseButton" /> <script type="text/javascript" event="onkeydown" for="document"> if(event.keyCode==13) { var button=document.getElementById("noUseButton"); button.focus(); button.onclick(); } </script> <script> function noClick() { return false; } </script>
方法三:
遮蔽頁面回車事件 ,在Form標識中加入如下內容:
method="post" onkeydown="if(event.keyCode==13) return false;"