开发者

alert should close after 5 seconds [duplicate]

开发者 https://www.devze.com 2023-03-29 17:52 出处:网络
This question already has answers here: Javascript close alert box (11 answers) Closed 5 years ago. I have simple javascript alert box i want it to c开发者_Go百科lose automatically after 5
This question already has answers here: Javascript close alert box (11 answers) Closed 5 years ago.

I have simple javascript alert box i want it to c开发者_Go百科lose automatically after 5 second. if possible help please.

<script type="text/javascript">
function show_alert()
{
alert("Hello! I am an alert box!");
}
</script>

<input type="button" onclick="show_alert()" value="Show alert box" />


You cannot close a JavaScript alert box, the user has to. If you want to do something like this, I suggest using a custom modal popup (like jQuery UI).


There is no way to close classic alert box. You can male your own using HTML + lock events, and use timer for closing.

0

精彩评论

暂无评论...
验证码 换一张
取 消