窗口打不开

来源:2-7 编程练习

qq_您_8

2018-03-07 19:11

<!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 open=confirm("确定打开新网址吗?);

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

    if(open==ture)

    { var url=prompt(确定打开的网址http://www.imooc.com/)

       

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

     if(url!=null)

   {window.open('url' '_blank' 'width=400px,height=500px');} //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。

    else

    {alert("打开失败");}

    else

    {alert("打开失败");}

    }

  </script> 

 </head> 

 <body> 

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

 </body>

</html>

请问为什么弹出alert窗口之后,就没有弹出输入网址的窗口

写回答 关注

2回答

  • Fightingn
    2018-03-07 20:28:21
    已采纳

    http://img4.mukewang.com/5a9fd904000138c705120393.jpg

    刚刚帮同学的代码测试了一下,发现同学的代码有些语法错误呀,

    1. open=true,而不是ture哦。。

    2. 格式:prompt("str1","str2"); 还有 window.open();

    3. 最后就是alert();  分号要用英文半角(程序的符号都要用英文半角呐)。

    qq_您_8

    非常感谢!

    2018-03-07 23:32:25

    共 1 条回复 >

  • Fightingn
    2018-03-07 19:50:10

    var url=prompt("确定打开的网址?","http://www.imooc.com/");

JavaScript入门篇

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

741024 学习 · 9681 问题

查看课程

相似问题