<html>
<body>
<h2>JavaScript Prompt</h2>
<button onclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction() {
var txt;
var person = prompt("Please enter your name:", "Harry Potter");
if (person == null || person == "") {
txt = "User cancelled the prompt.";
} else {
txt = "Hello " + person + "! How are you today?";
}
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<!-- Mirrored from www.w3schools.com/js/tryit.asp?filename=tryjs_prompt by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 27 Jan 2020 02:40:15 GMT -->
</html>