• JavaScript中的三种弹出框的区别与使用


    JavaScript中有三种原生的弹出框,分别是alert、confirm、prompt。分别表示弹出框、确认框、信息框。

    以下是示例代码:

    <!DOCTYPE html>
    <html>
        <head>
            <title>JavaScript中的三种弹出框</title>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
            
        </head>
        <body>
            <input type="submit" value="alert" onclick="alertExample()" />
            <input type="submit" value="confirm" onclick="confirmExample()" />
            <input type="submit" value="prompt" onclick="promptExample()" />
        </body>
        <script type="text/JavaScript">
            function alertExample(){
                alert("这是弹出框");
            }
    
            function confirmExample(){    
                var r=confirm("按下按钮");
                  if (r==true){
                    alert("您按了确认!");
                }else if(r==false){    
                    alert("您按了取消!");
                }
            }    
    
            function promptExample() {
                var score;//分数
                var degree;//等级
                score = prompt("你的分数是多少?");
                if (score > 100){
                    degree = '耍我?100分满分!';
                }else{
                    switch (parseInt(score / 10)) {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                        case 5:
                            degree = "恭喜你,又挂了!";
                            break;
                        case 6:
                            degree = "勉强及格";
                            break;
                        case 7:
                            degree = "凑合,凑合"
                            break;
                        case 8:
                            degree = "不错,不错";
                            break;
                        case 9:
                        case 10:
                            degree = "高手高手,佩服佩服";
                    }
                }
                alert(degree);
            }
        </script>
    </html>
  • 相关阅读:
    poj1459(多源点网络流)
    poj 2480
    poj1850和poj1496(组合数)
    poj3252(组合数)
    hdu1452(逆元)
    因子和与因子个数
    poj 2478(欧拉函数打表)
    p3807(lucas定理)
    F-有趣的数字(组合数+逆元)
    《Java并发编程的艺术》Java并发机制的底层实现原理(二)
  • 原文地址:https://www.cnblogs.com/wbxk/p/6714928.html
Copyright © 2020-2023  润新知