CBSE 5. WEB SCRIPTING - JAVA SCRIPT (5 MARKS)

 

13. Showing Prompt Box

JavaScript

<!DOCTYPE html>

<html>

<head>

<title>Prompt Box</title>

</head>

<body>

 

<script>

  var userName = prompt("Please enter your name:", "John Doe");

  if (userName != null) {

    alert("Hello " + userName + "!");

  }

</script>

 

</body>

</html>

This will display a prompt box where the user can enter their name.

No comments:

Post a Comment