烦请各位大神再来看下这里哪出错了,运行不了

来源:2-7 编程练习

活在梦里3980862

2016-10-16 00:25

<!DOCTYPE html>

<html>

 <head>

  <title> new document </title>  

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

  <script type="text/javascript">  

function foo(){

    var bli=confirm('确定打开新世界的大门吗?');

    if (bli==ture)

            {var url=prompt("在下面网址输入key就可以啦",'http://www.bilibili.com/');

            if (url!=null)

            {window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');}

        else {alert('prompt关闭');}

    else {alert('confirm关闭');}

    }}

  </script> 

 </head> 

 <body> 

 <input type="button" value="打开新世界的大门" onclick="foo()" /> 

 </body>

</html>


写回答 关注

6回答

  • 行走在二进制世界
    2016-10-16 09:55:24
    已采纳

    第一:if语句里面应该是true而不是ture;

    第二:prompt语句后面的分号要是英文输入下的,你用的是中文状态下的了;

    第三:第一个else后面应该跟一个分号表示第一个if语句结束,你把它放到最后去了


    行走在二进制... 回复活在梦里39...

    我这边是中文下的,如果是英文下的就没有问题

    2016-10-17 14:44:56

    共 5 条回复 >

  • 行走在二进制世界
    2016-10-17 14:50:03
    <!DOCTYPE html>
    <html>
     <head>
      <title> new document </title>  
      <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>   
      <script type="text/javascript">  
    function foo(){
        var bli=confirm('确定打开新世界的大门吗?');
        if (bli==true)//这里ture改为true
                {var url=prompt("在下面网址输入key就可以啦",'http://www.bilibili.com/');/*这里改为英文状态下的*/
                if (url!=null)
                {window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');}
            else {alert('prompt关闭');}}//这里加上一个括号
        else {alert('confirm关闭');}
        }//这里去掉一个括号
      </script> 
     </head> 
     <body> 
     <input type="button" value="打开新世界的大门" onclick="foo()" /> 
     </body>
    </html>


  • qq_空闲_04023095
    2016-10-16 19:24:49

    上面说得都对,嘻嘻

  • 刘平涛涛涛涛涛
    2016-10-16 10:01:47

      content="text/html" charset="gbk"/

     if(bil != null)


  • 刘平涛涛涛涛涛
    2016-10-16 10:00:38
    <!DOCTYPE html>
    <html>
     <head>
      <title> new document </title>  
      <meta http-equiv="Content-Type" content="text/html" charset="gbk"/>   
      <script type="text/javascript"> 
    function  foo()
          {
        var bil =confirm("是否打开大门");
         if(bil == true){
        var url = prompt("要去玩吗?","http://www.bilibili.com");}
         if(bil != null)
        {window.open(url,'_blank','width:400,height:500,menubar=no,toolbar=no');}
       else 
    	{alert("关闭");}  
       }
    </script>
    </head>
    <body>
    <input type="button" value="打开新世界的大门" onclick=" foo()" /> </body>
    </html>


  • 慕圣2955269
    2016-10-16 09:50:23

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

    多个)号

JavaScript入门篇

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

738661 学习 · 9561 问题

查看课程

相似问题