Alert, Prompt, Confirm

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Alert Box example

alert("do you really want to leave this page?");

Line breaks

To display line breaks within a popup box, use a backslash followed by the character n. alert("Hello/nHow are you?"); /* Be careful when using alert boxes, as the user can continue using the page only after clicking OK.*/

Confirm Box

A confirm box is often used to have the user verify or accept something. When a confirm box pops up, the user must click either ok or cancel to proceed. If the user clicks Ok, the box returns true. If the user clicks cancel, the box returns false. var result = confirm("Do you really want to leave this page?"); if(result == true) { alert("Thanks for visiting"); } else { alert("Thanks for staying with us."); }

Prompt box

A prompt box is often used to have the use input a value before entering a page. When a prompt box pops up , the user will have to click either OK or Cancel to proceed after entering the input value. If the user clicks OK, the box returns the input value. If the user clicks Cancel, the box returns "null".

The Alert Box

Javascript offers three types of popup boxes, the Alert, Prompt, and confirm boxes. 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.

Prompt method

The prompt() method takes two parameters. -The first is the label, which you want to display in the text box. -the second is a default string to display in the text box (optional). var username = prompt("Please enter your name"); alert(username);


Set pelajaran terkait

Marketing 3250 Chapter 2 Questions from Cengage

View Set

Application Development Lifecycle

View Set

Baylor University AS 1101 Exam 2 AFROTC

View Set

International Business Chapter 1

View Set

Guyton Chapter 61 - Autonomic Nervous System

View Set

Chapter 15 - Integrated Marketing Communications

View Set

Surgery 1001-1200 ចម្លើយពេញ

View Set

MindTap: Worksheet 13.2: Performance and Discharge

View Set