o So far, we have seen brief examples of alert, prompt and confirm dialogue boxes to request a response from the user, and to pause all code in the background until the request is satisfied.
o Because of this ubiquity, its presence is assumed even if it is omitted. Thus, where we technically should write:
it is equally valid to write:
as we have been doing.
o Similarly, instead of writing:
we can happily write:
o The prototypes of the three methods are:
window.alert( message ); window.confirm( message ); window.prompt( message, default_response );
o Alert will always return a value of “true” when it is cleared by clicking “ok”.
o Confirm will return either “true” or “false” depending on the response chosen to clear the box.
o Prompt will return either the value typed in, “null” if nothing is typed in, and “false” if the box is cancelled.
o Open your previous project file, and save it under the name chapter_10.html.
o Clear the previous redirection code, and ensure that the script tags have been returned to the head section of the document.
o Add a new statement to the script on the page that will display the following message before the rest of the page is shown:
Welcome to my website! Click OK to continue.
o Check your page in your browser.
o We will use alert, confirm, and prompt throughout this course. Take a moment to try each of them in turn on this page, each time stopping to review your changes.
o Use the write method of the document object to check the return values of each method. For example: