Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary JavaScript Tutorial: Interaction - Alert, Prompt, Confirm | Web Development Tutorials

Rating
-
Sold
-
Pages
10
Uploaded on
27-08-2023
Written in
2023/2024

Hello Student here is java coding for web development

Institution
Course

Content preview

JavaScript Tutorial: Interaction - Alert, Prompt,
Confirm |
Web Development Tutorials



How to Make a Page Interactive Using Alert, Prompt, and Confirm

In this tutorial, we will explore how to make a web page interactive using
JavaScript. Specifically, we will learn how to use the alert, prompt, and
confirm functions. These functions are essential for creating user
interactions on a website.



Alert Function

The alert function is used to display a message to the user. It opens a
modal window with the specified message.



To use the alert function, simply call it and pass a string as an argument.
For example:



alert("This is a message");

When the code above is executed, a modal window with the message "This
is a message" will be displayed on the webpage.



It's important to note that the alert function does not return anything.



Prompt Function

, The prompt function is used to ask the user for input. It opens a modal
window with a message and an input field for the user to enter their
response.



To use the prompt function, call it and assign the user's input to a variable.
For example:



let name = prompt("What is your name?", "Guest");

In the code above, the prompt function will display the message "What is
your name?" and provide a default value of "Guest" in the input field. The
user's input will be stored in the variable "name".



It's important to note that the prompt function returns the user's input as a
string.



Confirm Function

The confirm function is used to ask the user for confirmation. It opens a
modal window with a message and two buttons: "OK" and "Cancel".



To use the confirm function, call it and assign the result to a variable. For
example:



let deletePost = confirm("Do you really want to delete this post?");

In the code above, the confirm function will display the message "Do you
really want to delete this post?" and wait for the user to click either "OK" or
"Cancel". The result of the confirmation will be stored in the variable
"deletePost".

Written for

Course

Document information

Uploaded on
August 27, 2023
Number of pages
10
Written in
2023/2024
Type
SUMMARY

Subjects

$10.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
mohdasar

Get to know the seller

Seller avatar
mohdasar glitter
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
2
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions