Summary
-
The
alert
function shows a modal window with a text message and waits for the user to press “OK”. The word “modal” means that the visitor cannot interact with the rest of the page until they have dealt with the window. -
The
prompt
function shows a modal window with a text message asking the user to input text. It returns the text or, ifCancel
button orEsc
is clicked,null
(in IE instead ofnull
the returned value isundefined
). -
The
confirm
function shows a modal window with a message and waits for the user to press OK or Cancel. It returnstrue
for OK andfalse
forCancel/Esc
.
Tasks
-
A simple page
name = prompt("name: ", "") alert(name)