How to demonstrate a prompt box in javascript?

How to demonstrate a prompt box in javascript?, someone asked me to explain?

In this article we will discuss to to demonstrate a prompt box in javascript. When the user click’s the button event will be raise it calls the javascript function there we have implement prompt box.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
    <title>demonstrate theprompt box</title>
    <p>Click the button to demonstratethe prompt box.</p>
    <button onclick="myFunction()">Try it</button>
    <p id="message"></p>
    <script type="text/javascript">
        function myFunction() {
            var person = prompt("Please enter your name", "shahrukh khan");
            if (person != null) {
            "Hello " + person + "! How are you today?";


demonstrate a prompt box

Post your comments / questions