Changes

Jump to: navigation, search

JavaScript Window Object

636 bytes added, 18:30, 10 May 2007
Displaying Message Box Dialogs
</pre>
* '''confirmation''' - used when a yes or no response needs to be obtained from the user. This dialog type displays with a message and "OK" and "Cancel" buttons. The ''confirm()'' method takes the message to be displayed to the user as an argument and retruns true or false depending on whether the user pressed "OK" or "Cancel":
<pre>
<input type="button" value="Show Confirmation" onclick="showConfirmation()" />
</form>
 
* '''prompt''' - designed to enable information to be obtained from the user. The dialog conists of a message to the user, a text input field for the entry of data and OK and Cancel buttons. The ''prompt()'' method takes the message to be displayed as an argument and retruns the value entered by the user:
 
<pre>
 
<script language="JavaScript" type="text/javascript">
 
function showPrompt()
{
var userInput = prompt("Please enter your name:");
 
document.write("Hello, " + userInput);
}
</script>
 
<form action="null">
<input type="button" value="Show Prompt" onclick="showPrompt()" />
</form>
 
</pre>

Navigation menu