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

用这段代码打开新窗口总显示无法访问,能帮我看看这段代码有什么问题吗?

用这段代码打开新窗口总显示无法访问,能帮我看看这段代码有什么问题吗?

慕粉4078561 2016-10-06 11:13:53
<!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 mymessage=confirm("你确定要打开新窗口吗?");       if(mymessage==true)       {var mynum=prompt("输入网址:","http://www.imooc.com/");       if(mynum!=null)       {window.open('mynum','_blank','width=400,height=500,menubar=no,toolbar=no,status=yes,scrollbars=yes');}              else{alert("返回");}       else{alert("返回");} }        </script>  </head>  <body>    <input type="button" value="新窗口打开网站" onclick="openWindow()" />  </body></html>
查看完整描述

2 回答

?
kofzxaaa

TA贡献66条经验 获得超26个赞

额,你那个'mynum'把单引号去掉即可。

参考代码:

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>
	<body>
		 <input type="button" value="新窗口打开网站" onclick="openWindow()" />
		 
		<script>  
    
   function openWindow(){
       var mymessage=confirm("你确定要打开新窗口吗?");
       if(mymessage==true)
       {
       	var mynum=prompt("输入网址:","http://www.imooc.com/");
       if(mynum!=null)
       {
       	window.open(mynum,'_blank','width=400,height=500,menubar=no,toolbar=no,status=yes,scrollbars=yes');
       }
       
//     else{alert("返回");}
       
//else{alert("返回");}
       }  
   }
  </script> 
	</body>
</html>

还有你少了个}。

查看完整回答
1 反对 回复 2016-10-06
  • 2 回答
  • 0 关注
  • 1248 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信