window.prompt()

In this chapter you will learn:

  1. Show the prompt() dialog

Prompt dialog

prompt() dialog prompts the user for input.

<!DOCTYPE HTML> <!--from  j  a  va  2  s. c  om-->
<html> 
    <body> 
        <script type="text/javascript"> 
                var result = prompt("What is your name? ", ""); 
                if (result !== null) { 
                    document.writeln("Welcome, " + result); 
                } 


        </script> 
    </body> 
</html>

Click to view the demo

Next chapter...

What you will learn in the next chapter:

  1. How to resize a window in Javascript
Home » Javascript Tutorial » Window
Window Object
alert()
close()
confirm()
find()
Window height and width
location
window.moveBy
window.moveTo
window.open()
window.print()
window.prompt()
resizeTo(x,y) and resizeBy(xDelta,yDelta)
window.scrollTo(x,y)
screenLeft, screenX, screenTop, screenY
setInterval()
setTimeout()