<html>
<body>
<p>Click the button to demonstrate the prompt box.</p>
<button οnclick="myFunction()">Try it</button>
<p id="demo"></p>
<script>
function myFunction()
{
var x;
var person=prompt("Please enter your name","Sharejs.com");
if (person!=null)
{
x="Hello " + person + "! How are you today?";
document.getElementById("demo").innerHTML=x;
}
}
</script>
</body>
</html>
//该代码片段来自于: http://www.sharejs.com/codes/javascript/7831