美文网首页
JavaScript中confirm,alert,prompt的

JavaScript中confirm,alert,prompt的

作者: 风语安然 | 来源:发表于2015-11-09 00:27 被阅读117次

    好吧,一直容易忘,做个备份。

    window.confirm 参数就只有一个。显示提示框的信息。按确定,返回true;按取消返回false。

    var bln = window.confirm("确定吗?");

    //(yes->return true,no-return false)

    alert(bln);

    window.alert参数,只有一个,显示警告框的信息;无返回值。

    window.alert("确定");

    window.prompt参数,有两个,第一个参数,显示提示输入框的信息。第二个参数,用于显示输入框的默认值。返回,用户输入的值。

    var str = window.prompt("请输入密码","password")

    alert(str);  //print what you entered

    相关文章

      网友评论

          本文标题:JavaScript中confirm,alert,prompt的

          本文链接:https://www.haomeiwen.com/subject/xkzchttx.html