alert()
Very simply displays a popup alert box, with a single OK button:
alert("Message goes here!");
prompt()
Displays a prompt box, requesting text to be entered, which can be assigned to a variable:
<html> <head> <title>JavaScript</title> </head> <body> <script> var myName = prompt("Please enter your name."); document.write("You entered: " + myName); </script> </body> </html>
confirm()
Displays popup confirmation box with OK and cancel buttons:
<html> <head> <title>JavaScript</title> </head> <body> <script> var cont = confirm("Do you want to carry on?"); if (cont) { document.write("You pressed OK."); return true } else { document.write("You pressed cancel."); return false } </script> </body> </html>
To get a new line in a dialogue box use the escaped \n sequence.