1

I have simple javascript alert box i want it to close 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" />
DenisPostu
  • 599
  • 3
  • 10

2 Answers2

9

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).

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
  • actually i have a feedback form on site and i want after form submission user should get java alert box of successful submission. and it should close automatically. well do u think jquery modal popup will be fine for this. i just want your opinion. – Abdul Shakoor Kakar Aug 22 '11 at 19:59
2

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

gen_Eric
  • 223,194
  • 41
  • 299
  • 337
SergeS
  • 11,533
  • 3
  • 29
  • 35