JavaScript prompt - Dialog box
Description
The alert() method can not interact with the visitor. To interact with the user we use prompt(), which asks the visitor to input some information and stores the information in a variable.
See the following web document.
Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset=utf-8> <title>JavaScript prompt() example-2</title> </head> <body> <script type="text/javascript"> visiter_name = prompt("Input your name : ") if(visiter_name != null && visiter_name != "") alert("Your Name is : "+visiter_name); else alert("Blank name ...!") </script> </body> </html>
View the example in the browser
Supported Browser
Internet Explorer 7 | Firefox 3.6 | Google Chrome 7 | Safari 5.0.1 | Opera 10 |
Yes | Yes | Yes | Yes | Yes |