Javascript code to display using a prompt box
Javascript code to display a welcome message after accepting the name of the user using a prompt box
Click the button than show prompt window (Please Enter Your Name)
And ok or enter press than show Welcome to Your Name
- <!DOCTYPE html>
- <html>
- <head>
- <title>
- Window prompt() Method
- </title>
- <script>
- function techorj() {
- var doc = prompt("Please Enter Your Name", "");
- if (doc != null) {
- alert("Welcome to "+doc);
- }
- }
- </script>
- </head>
- <body style="text-align: center;">
- <h1 style="color:red;">
- Techorj.com(Techno Rajput)
- </h1>
- <h2>
- Window prompt() Method
- </h2>
- <button onclick="techorj()">
- Click me!
- </button>
- <p id="g"></p>
- </body>
- </html>
Output
Welcome to your Name Here
Javascript code to display using a window prompt box
Reviewed by Kshatriya Mahipal Singh
on
May 02, 2020
Rating:
No comments: