METHOD:  Window::confirm


confirm("message")

This method brings up a dialog box that prompts the user to select either 'o.k.' or 'cancel', the first returning true and the latter, false.

The following example opens a new window, creates a button in the original window and assigns the closeWindow() function to its onClick event handler. This function prompts the user to confirm the closing of the new window.

Code:
<form action="" method="POST" id="myForm">
<input type="Button" name="" value="Close" id="myButton" onClick="closeWindow()">

<script type="" language="JavaScript">

myWindow = window.open("", "tinyWindow", 'toolbar, width=150, height=100')

function closeWindow() {
       myWindow.document.write("Click 'O.K'. to close me and 'Cancel' to leave me open.")
       if (confirm("Are you sure you want to close this window?")) {
              myWindow.close()
       }
}

</script>
</form>

 
Output:


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information