为什么我用了prompt不起作用,请帮我看看
window.open怎么没起作用?

老师的这段代码,啥意思

window.open怎么没起作用?

老师的这段代码,啥意思

2015-12-15
function openWindow()
{var open=confirm("确认新建窗口打开网站吗?");
if(open==true)
// 新窗口打开时弹出确认框,是否打开
{var mychar=prompt("通过输入对话框,确定打开的网址","http://www.imooc.com");
if(mychar!=null)
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
{window.open(mychar,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');
}
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("不能打开!");}
}
}这样写
兄弟,你看这样写是不是更简洁些,我想了想
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>我爱编程</title>
<script type="text/javascript">
function openWindow()
{
if(confirm("确认新建窗口打开网站吗?"))// 新窗口打开时弹出确认框,是否打开
{
var mychar=prompt("通过输入对话框,确定打开的网址","http://www.imooc.com");
if(mychar!=null)// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com
{window.open(mychar,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');
} //打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{
alert("不能打开!");}
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>举报