|
|
|
The methods of window object determine how window object performs actions, such as how it displays a message or get input from the user. The most used window methods are given below. alertThe alert method displays an alert message box. The alert message box is similar to the regular message box of the Windows user interface. It displays a message and remains on the screen, and the execution of the script is suspended until the user clicks the OK button. You can use the alert method for displaying messages to the user; its syntax is alert("Please, enter a valid user name")confirmThe confirm method displays a message box similar to the alert method, only this box has two buttons, OK and Cancel. The confirm method returns the value True if the OK button is clicked and the value False if the Cancel button is clicked. This method is frequently used to notify the user that an important action is about to take place, such as the transmission of Form data to the server. Here's how the confirm method is typically used: x=window.confirm("Are you ready to submit the data?")
if x=True Then Form.submitpromptThe prompt method prompts the user for data, much like the InputBox() function. The prompt method accepts two arguments, the prompt for the user and an optional default response, and returns the data supplied by the user. For example, the following code asks the user to enter a year, giving No as the default value. x=prompt("Quit application? Enter Yes or No", "No") Whatever the user has entered in the box gets stored in the x variable, which can later be used in the code. If the user simply clicks OK without entering any information, the No(default response) is returned. openThe open method opens an existing window, or creates a new one and displays a document in it. The simplest form of the open method is window.open url, target where url is the URL of the document to be displayed in the new window and target is the name of the window in which the document will appear. If the window specified with this name exists, this window's contents get replaced by the new document. If not, a new window with this name is opened and the document displays in it. The optional target argument is identical to the TARGET attribute of the <HREF> tag. closeThe close method closes an open window. If you have opened a window with the following statement Go To Page: 1 2
The copyright of the article Methods of Window Object in VB Script is owned by . Permission to republish Methods of Window Object in print or online must be granted by the author in writing.
|
|
|
|
|
|
|
|