How to use Window Object Prompt in JavaScript

In this article I am going to explain about window object prompt() method in JavaScript.
  • 2096

JavaScript Window Object Prompt() Method

JavaScript Prompt() Method use for open a dialog box that take input from user. Prompt dialog box return a string value that entered by user.



Window.Prompt(Message,Default display text)




    <p id="tst">


    <script type="text/javascript">

        function myfun() {

            var mm;


            var name = prompt("Enter Your Name", "prabhakar");


            if (name != null) {

                mm = "Hello " + name;

                document.getElementById("tst").innerHTML = mm;






    <button onclick="myfun()">

        click me</button>






Enter value and click ok



You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.