Display a welcome message after the name by prompt box

This is the html code. Please follow the below steps to run this code.

  1. Open notepad
  2. Copy the below code to the notepad.
  3. Goto File -> Save as
  4. Select All Files in type.
  5. Enter the file name and click Save.

After performing all these steps, double click the saved Html/Javascript file and it will appear in the browser.

<!DOCTYPE html>
<html>
<body>
	<h2>Your name will be dispalyed below</h2>
	<p id="message_id"></p>
	
	<script>
		var textMessage = prompt("Kindly enter your name here: ", "Mohit Singla");
    
		document.getElementById("message_id").innerHTML = 'Welcome <b>' + textMessage +'</b>. You are new visitor to our webpage';
    </script>
</body>
</html>
Output

Please comment below for more queries regarding this article.

Leave a Reply