我这段代码不能运行,why?

来源:2-7 编程练习

DM_耿

2016-02-17 23:37

<!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 wop=confirm("你确定要打开吗?");

        if(wop==true){

            var www = prompt("您确定要打开慕课网吗?"," http://www.imooc.com/") ;

            if(www!=null){

                window.open(www,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');

            }else{

            alert("退出成功!");

        }else{

        alert("退出成功!"); 

        }

    // 新窗口打开时弹出确认框,是否打开


    // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/


    //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。

    

    

  </script> 

 </head> 

 <body> 

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

 </body>

</html>


写回答 关注

1回答

  • DM_耿
    2016-02-17 23:54:06


    错误原因是少了没有大括号

    <!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 wop=confirm("你确定要打开吗?");

            if(wop==true){

                var www = prompt("您确定要打开慕课网吗?"," http://www.imooc.com/") ;

                if(www!=null){

                    window.open(www,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');

                }else{

                alert("退出成功!");}

            }else{

            alert("退出成功!"); 

             }

            }

        // 新窗口打开时弹出确认框,是否打开


        // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/


        //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。

        

        

      </script> 

     </head> 

     <body> 

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

     </body>

    </html>


JavaScript入门篇

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

741269 学习 · 9867 问题

查看课程

相似问题