无法弹出prompt框,求解救!!!

来源:2-7 编程练习

Lgpink

2016-01-09 01:34

<!DOCTYPE html>
<html>
 <head>
  <title> new document </title> 
  <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>  
  <script type="text/javascript"> 
    function openWindow(){
        var ahou=confirm("shi fou da kai?");
        if(ahou==ture)
        {
            var url=prompt("通过输入对话","http://www.imooc.com");
           
            window.open(url,"_blank",'width=400,height=500');   
            }
            else
            {
            alert("shu ru zheng que wang zhi");   
            }
          
        }
        else{alert("da kai shi bai");}
        }
  </script>
 </head>
 <body>
      <input type="button" value="新窗口打开网站" onclick="openWindow()" />
 </body>
</html>

写回答 关注

2回答

  • 馨迤
    2016-01-09 13:20:20

    <!DOCTYPE html>

    <html>

    <head>

    <title> new document </title>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <script type="text/javascript">

    function openWindow() {

    var ahou = confirm("shi fou da kai?");

    if (ahou == true) {

    var url = prompt("通过输入对话", "http://www.imooc.com");

    window.open(url, "_blank", 'width=400,height=500');

    } else {

    alert("shu ru zheng que wang zhi");

    }

    }

    </script>

    </head>

    <body>

    <input type="button" value="新窗口打开网站" onclick="openWindow()" />

    </body>

    </html>


    馨迤

    你的else出现了两遍,而且true拼写错了

    2016-01-09 13:21:10

    共 1 条回复 >

  • 情商低的单身汪汪
    2016-01-09 06:17:36

      <script type="text/javascript"> 
       function openWindow(){
            var ahou=confirm("shi fou da kai?");
            if(ahou)
            {
                var url=prompt("通过输入对话","http://www.imooc.com");
                if(url=="http://www.imooc.com")
                 window.open(url,"_blank",'width=400,height=500');
                else
                alert("shu ru zheng que wang zhi");
            }
            else
            alert("da kai shi bai");
            }
      </script>

JavaScript入门篇

JavaScript做为一名Web工程师的必备技术,本教程让您快速入门

739817 学习 · 9566 问题

查看课程

相似问题