window的三种系统弹框介绍

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        /* 001-弹出对话框,作用是提示用户 alert() */
        // alert(123);

        /* 002-弹出对话框,拥有取消和确定两个按钮,confirm()   */
        // var flag = confirm("确定要删除核按钮的密码吗?");
        /* 如果点击的是确定,返回true 取消那么返回的是false */
        // console.log(flag);

        /* 003 弹出输入框,标题 && 输入框 && 取消 && 确定*/
        // var res = prompt("请输入您的昵称?");
        var res = window.prompt("请输入您的昵称?", "小妖怪");
        /* 确定:输入框的内容 */
        /* 取消:null */
        console.log(res);
        /* 上面的这三个方法都是window的方法 */
        console.log(window.prompt == prompt, alert == window.alert); /* true trues */
    </script>
</body>

</html>
原文地址:https://www.cnblogs.com/huayang1995/p/12077333.html