简体   繁体   English

如何使用Enter键关闭Javascript Alertbox

[英]How to close Javascript alertbox by using the enter key

How to close Javascript alertbox by using the enter key.. 如何使用Enter键关闭Javascript Alertbox。

function validate(){
     if (document.getElementById("<%=username.ClientID%>").value == "") {
         alert("Please select UserID.");              
         return false;
     }
}

Actually I'm using custom Alert like: Var msg=new alert(); 实际上,我使用的是自定义提醒,例如:Var msg = new alert(); This is not closing... 这还没结束...

There is no way to control an alert() other than initially creating it. 除了最初创建alert()没有其他方法可以控制它。 There are no events and no way of changing it once it is created. 一旦创建,就没有事件,也没有办法对其进行更改。 If you need more control, consider creating a modal dialog, for example with jQuery UI. 如果需要更多控制,请考虑创建一个模式对话框,例如使用jQuery UI。

Docs 文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM