问答详情
源自:2-7 编程练习

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

<!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>

提问者:Lgpink 2016-01-09 01:34

个回答

  • 馨迤
    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>


  • 情商低的单身汪汪
    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>