<!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 what=confirm("是否打开?");
if(what=true){
var when=prompt("请输入网址","http://www.imooc.com");
if(when!=null){
window.open('http://www.imooc.com','_blank','width=400,weight=500,menubar=no,toolbar=no');
else{
alert("谢谢!");
else{
alert("谢谢!")
}
}
}
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
你没有发现你的if。。。else。。写错了吗 else是必须哟啊配合if使用的,不能够单独使用,
function openWindow(){
var what=confirm("是否打开?");
if(what==true){
var when=prompt("请输入网址","http://www.imooc.com");
if(when!=null){
window.open(when,'_blank','width=400,weight=500,menubar=no,toolbar=no');}
else{alert("谢谢!");}}
else{
alert("谢谢!")}
}