Alert, Prompt, Confirm part 1

JavaScript Tutorial
Functions
Alert, Prompt, Confirm
4
1/3
               

The Alert Box



JavaScript offers three types of popup boxes, the AlertPrompt, and Confirm boxes.

Alert Box


An alert box is used when you want to ensure that information gets through to the user.
When an alert box pops up, the user must click OK to proceed.
The alert function takes a single parameter, which is the text displayed in the popup box.
Example:
alert("Do you really want to leave this page?"); Try It Yourself

Result:
To display line breaks within a popup box, use a backslash followed by the character n.
alert("Hello\nHow are you?");Try It Yourself

Result:
Be careful when using alert boxes, as the user can continue using the page only after clicking OK.

Comments

Popular posts from this blog

String Operators

Introducing object part 3

The math object part 2