为什么我这句代码没执行

沐梓弦乐 2015-04-11 03:35:08
<!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 ow=confirm("是否打开?")

if(ow == true){

var url = "http://www.imooc.com";

var newurl = prompt("确认打开一个新的网页",url);

if(newurl == true)
{
window.open('http://www.baidu.com','_blank','width=400,height=500');
}

}else{
alert("为什么没打开");
}
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/

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


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

就是这句代码window.open('http://www.baidu.com','_blank','width=400,height=500'); 为什么没有执行 我把它放到函数的第一行也是没有执行 请问各位同行是为什么呢
...全文
193 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
冰若辰 2015-04-12
  • 打赏
  • 举报
回复
alert(“为什么没打开”); 这句你结尾的分号写成中文的了!
slwsss 2015-04-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 ow=confirm("是否打开?") 
    
    if(ow == true){
        
    var url = "http://www.imooc.com";
    
    var newurl = prompt("确认打开一个新的网页",url);
    
   if(newurl)
   {
     window.open('http://www.baidu.com','_blank','width=400,height=500');
   }
     
    else{
        alert("......")
    }}
    }
    // 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/

    //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
    
    
  </script> 
 </head> 
 <body> 
  <input type="button" value="新窗口打开网站" onclick="openWindow()" /> 
 </body>
</html>

87,921

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧