alert
Displays an Alert dialog box with a message and an OK button.
方法源 Window
实现版本 Navigator 2.0
语法
alert("message")
参数
message A string.
描述
An alert dialog box looks as follows:
Use the alert method to display a message that does not require a user decision. The message argument specifies a message that the dialog box contains.
You cannot specify a title for an alert dialog box, but you can use the open method to create your own alert dialog box. See open.
示例
In the following example, the testValue function checks the name entered by a user in the Text object of a form to make sure that it is no more than eight characters in length. This example uses the alert method to prompt the user to enter a valid value.
function testValue(textElement) {
if (textElement.length > 8) {
alert("Please enter a name that is 8 characters or less")
}
} You can call the testValue function in the onBlur event handler of a form's Text object, as shown in the following example: