Web site - 277Chapter 16 .Window and Frame Objects The value
277Chapter 16 .Window and Frame Objects The value returned by this method is a string in the dialog box s field when the user clicks the OK button. If you re asking the user to enter a number, remember that the value returned by this method is a string. You may need to perform data- type conversion with the parseInt()or parseFloat()functions (see Chapter 42) to use the returned values in math calculations. When the user clicks the prompt dialog box s OK button without entering any text into a blank field, the returned value is an empty string ( ). Clicking on the Cancel button, however, makes the method return a null value. Therefore, the scripter must test for the type of returned value to make sure that the user entered some data that can be processed later in the script, as in var entry = prompt( Enter a number between 1 and 10: , ) if (entry != null) { //statements to execute with the value } This script excerpt assigns the results of the prompt dialog box to a variable and executes the nested statements if the returned value of the dialog box is not null (if the user clicked the OK button). The rest of the statements then include data validation to make sure that the entry is a number within the desired range (see Chapter 43). It may be tempting to use the prompt dialog box as a handy user input device. But, as with the other JavaScript dialog boxes, the modality of the prompt dialog box is disruptive to the user s flow through a document and can also trap automated macros that some users activate to capture Web sites. In forms, HTML fields are better user interface elements for attracting user text entry. Perhaps the safest way to use a prompt dialog box is to have it appear when a user clicks a button element on a page and then only if the information you require of the user can be provided in a single prompt dialog box. Presenting a sequence of prompt dialog boxes is downright annoying to users. On the CD-ROM Example (with Figure 16-13 and Listing 16-29) on the CD-ROM Related Items: window.alert(), window.confirm() method. releaseEvents(eventTypeList) Returns: Nothing. NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . If your scripts have enabled NN4-specific event capture for the windowobject (or documentor layer, for that matter), you can turn off that capture with the releaseEvents() method. This method does not inhibit events from reaching windowObject.releaseEvents()
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.