var mm = prompt("提示", "缺省值");
alert(mm);

解决方案 »

  1.   

    <html>
    <head>
    <title>
    </title>
    <script language="javascript">
    <!--
    function show()
    {
      var name
      name=window.prompt("please enter your name:","")
      window.alert(name)}
    //-->
    </script>
    </head>
    <body>
    <input type="button" name="button1" value="click"  onclick="show()">
    </body>
    </html>
    这个例子是点击按钮才出现对话框,且名字是由一新的窗口显示。如果想显示到页面上,只用把
    window.alert(name)换成:
    document.write(name)
    document.close()
    如果想页面完全载入后直接弹出窗口,则如下:
    <html>
    <head>
    <title>
    </title>
    <script language="javascript">
    <!--
    function show()
    {
      var name
      name=window.prompt("please enter your name:","")
      document.write(name)
      document.close()
    }
    //-->
    </script>
    </head>
    <body onload="show()">
    </body>
    </html>
      

  2.   

    prompt method
    Displays a Prompt dialog box with a message and an input field. 语法
    prompt(message, [inputDefault])
    message is any string or a property of an existing object; the string is displayed as the message. 
    inputDefault is a string, integer, or property of an existing object that represents the default value of the input field.
      

  3.   

    prompt("title","value")
    alert("msg")
    confirm("msg")
      

  4.   

    confirm("msg")返回yes or no
      

  5.   

    function inp()
    {
     var msg;
     msg=prompt("请输入字符串:","输入这里");
    alert("输入信息是:"+msg);
    }
      

  6.   

    可以,用window.open或showmodeldialg做