JavaScript中的三種彈出框

來源:互聯網
上載者:User

標籤:nbsp   color   彈出框   code   switch   tle   confirm   多少   onclick   

 1 <!DOCTYPE html> 2 <html> 3     <head> 4         <title>JavaScript中的三種彈出框</title> 5         <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 6         <script type="text/JavaScript"> 7             function alertExample(){ 8                 alert("這是彈出框"); 9             }10             11             function confirmExample(){    12                 var r=confirm("按下按鈕");   13                   if (r==true){14                     //document.write("您按了確認!");15                     alert("您按了確認!");16                 }else if(r==false){    17                     //document.write("您按了取消!");18                     alert("您按了取消!");19                 }20             }    21 22             function promptExample() {23                 var score;//分數24                 var degree;//分數等級25                 score = prompt("你的分數是多少?");26                 if (score > 100){27                     degree = ‘耍我?100分滿分!‘;28                 }else{29                     switch (parseInt(score / 10)) {30                         case 0:31                         case 1:32                         case 2:33                         case 3:34                         case 4:35                         case 5:36                             degree = "恭喜你,又掛了!";37                             break;38                         case 6:39                             degree = "勉強及格";40                             break;41                         case 7:42                             degree = "湊合,湊合"43                             break;44                         case 8:45                             degree = "不錯,不錯";46                             break;47                         case 9:48                         case 10:49                             degree = "高手高手,佩服佩服";50                     }51                 }52                 alert(degree);53             }54         </script>55     </head>56     <body>57         <input type="submit" value="alert" onclick="alertExample()" />58         <input type="submit" value="confirm" onclick="confirmExample()" />59         <input type="submit" value="prompt" onclick="promptExample()" />60     </body>61 </html>

 

JavaScript中的三種彈出框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.