How can I create a popup message window that will close itself after 'n' seconds?

Jorge Jordão

None of the predefined dialogs (alert, confirm, prompt) allow you to do that.

However, you can create your custom dialog window with, and using setTimeout(function, msecs) you can close it after a specified time.


MyDialog.html (HTML content for the dialog window)

    <TITLE>This is my custom dialog</TITLE>
    <FONT FACE="Arial" SIZE="2">
      This is my custom dialog message</FONT>
      <INPUT TYPE="button" VALUE="    OK    "  

Test.html (page that opens a dialog and closes it after a specified time)

    <SCRIPT LANGUAGE="JavaScript">
      function closeDialog() {
      var dialog ="custom2.html","mywindow",
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact