哪里错了,请指示下

来源:2-7 编程练习

qq_PureBLACK_13313525

2016-05-08 11:26

<!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 sb=confirm("确认要打开网站?")

    if(sb==true)

    {var sp=prompt("是否要打开此网页",http://www.imooc.com/)

    if(sp==true)

    {window.open("http://www.imooc.com/","_blank","width=400px","height=500px","munebar=no","toolbar=no")}

    else

    {alert("再见")}

    }

    else

    {alert("再见")}

      </script> 

 </head> 

 <body> 

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

 </body>

</html>


写回答 关注

4回答

  • 安心的温柔
    2016-05-09 15:17:44

    confirm的{}大括号里面,弹出我看前面介绍的是document.write

  • 安心的温柔
    2016-05-09 15:16:28

    window.open()括号里面是单引号

  • LieberLee
    2016-05-08 15:10: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 sb=confirm("确认要打开网站?");

        if(sb==true)

        {

    var sp=prompt("是否要打开此网页","http://www.imooc.com/");    //逗号错了,用了全角的,下面一些符号也是,另外语句末尾要加分号

        if(sp!=null)

    /*

    这里不能用“sp==true”,因为其返回值为:

    1. 点击确定按钮,文本框中的内容将作为函数返回值
    2. 点击取消按钮,将返回null
    */

        {window.open("http://www.imooc.com/","_blank","width=400px,height=500px,munebar=no,toolbar=no");}

        else

        {alert("再见");}

        }

        else

        {alert("再见");}

       }

      </script> 

     </head> 

     <body> 

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

     </body>

    </html>


  • 慕粉3315217
    2016-05-08 11:40:32

    <head>

     <title> new document </title>

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

     <script type="text/javascript">

      function openWindow(){

       var sb=confirm("确认要打开网站?")

       if(sb=true)

       {

         window.open("http://www.imooc.com/","_blank","width=400,height=500,munebar=no,toolbar=no")}

       else

       {

         alert("再见")

       }

     }

    </script>

    </head>

    <body>

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

    </body>

    </html>



JavaScript入门篇

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

742055 学习 · 9869 问题

查看课程

相似问题