Sunday, 6 April 2014

Popup Boxes in JavaScript

You can easily create Popup Boxes using JavaScript. Many developers and designers use them to interact with the user in three different ways:
  1. Alert Box

  2. Prompt Box

  3. Confirm Box

Before starting with the above shown Popup Boxes, run some programs in JavaScript using the following links:

Alert Box

It can be displayed using alert() function. In this user have to click "OK" to proceed.

Syntax: window.alert("message");
Example: alert("This is an alert box");

Alert Box in JavaScript
Alert Box

Prompt Box 

It is used to get data from user. It has a "OK" and "Cancel Button". Can be displayed using prompt() function.

Syntax: window.prompt("message","the DefaultText");
Example: prompt("Enter your website name","website");

Prompt Box in JavaScript
Prompt Box

Confirm Box 

This box is used to Verify and Accept something which means to let users make any choice. It can be displayed using confirm() function.
Syntax: window.confirm("message");
Example: confirm("This is, Click Ok or Cancel!");

Confirm Box in JavaScript
Confirm Box

Note: Running the above on Linux Ubuntu 13.10, so the GUI may differ in other Operating Systems.

No comments:

Post a Comment