为了账号安全,请及时绑定邮箱和手机立即绑定

哪里错了,请指示下

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

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

0 回复 有任何疑惑可以回复我~

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

0 回复 有任何疑惑可以回复我~

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


1 回复 有任何疑惑可以回复我~

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



1 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消

哪里错了,请指示下

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号