function disp_prompt(){ var name=prompt("请输入您的姓名","123"); if (name!=null && name!="") { document.write("您好," + name + "!"); } }
<html> <head> <title>提示框</title> </head> <body> <form action="" method="post"> <input type="button" onclick="disp_prompt()" value="显示确认框"> </form> </body> </html>