Javascript code to display using a window prompt box

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


  1. <!DOCTYPE html
  2. <html> 
  3.   
  4. <head> 
  5.     <title> 
  6.         Window prompt() Method 
  7.     </title> 
  8.   
  9.     <script> 
  10.         function techorj() { 
  11.             var doc = prompt("Please Enter Your Name",  ""); 
  12. if (doc != null) { 
  13.               alert("Welcome to "+doc); 
  14.                 } 
  15.         } 
  16.     </script>

  17. </head> 
  18.   
  19. <body style="text-align: center;"> 

  20.     <h1 style="color:red;"> 
  21.        Techorj.com(Techno Rajput)
  22.     </h1> 

  23.     <h2> 
  24.         Window prompt() Method 
  25.     </h2> 
  26.   
  27.     <button onclick="techorj()"> 
  28.         Click me! 
  29.     </button> 

  30.     <p id="g"></p> 
  31.  
  32. </body> 
  33.   
  34. </html> 



Output


Welcome to your Name Here


Javascript code to display using a window prompt box Javascript code to display using a window  prompt box Reviewed by Kshatriya Mahipal Singh on May 02, 2020 Rating: 5

No comments:

Powered by Blogger.