Home
Recent Q&A
Java
Cloud
JavaScript
Python
SQL
PHP
HTML
C++
Data Science
DBMS
Devops
Hadoop
Machine Learning
Azure
Blockchain
Devops
Ask a Question
What are the pop-up boxes available in JavaScript?
Home
JavaScript
What are the pop-up boxes available in JavaScript?
0
votes
asked
Jun 9, 2022
in
JavaScript
by
sharadyadav1986
What are the pop-up boxes available in JavaScript?
pop-up-box
Please
log in
or
register
to answer this question.
1
Answer
0
votes
answered
Jun 9, 2022
by
sharadyadav1986
Below are some examples of popup boxes in javascript
Alert Box
Confirm Box
Prompt Box
Example of alert() in JavaScript
<
script
type
=
"text/javascript"
>
function msg(){
alert("Hello Alert Box");
}
</
script
>
<
input
type
=
"button"
value
=
"click"
onclick
=
"msg()"
/>
Example of confirm() in JavaScript
<
script
type
=
"text/javascript"
>
function msg(){
var
v
=
confirm
("Are u sure?");
if(
v
==true){
alert("ok");
}
else{
alert("cancel");
}
}
</
script
>
<
input
type
=
"button"
value
=
"delete record"
onclick
=
"msg()"
/>
Example of prompt() in JavaScript
<
script
type
=
"text/javascript"
>
function msg(){
var
v
=
prompt
("Who are you?");
alert("I am "+v);
}
</
script
>
<
input
type
=
"button"
value
=
"click"
onclick
=
"msg()"
/>
...