<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>新打开窗口编程</title>
<script type="text/javascript">
function WindowOpen(){
var New=confirm("是否打开");
if (New==true){
var new2=prompt("请输入你要打开的网站","https://www.baidu.com/");
return new2
if (new2==null){
window.close()
}
else{
window.open(new2,"_blank",width=400,height=500,menubar=no,toolbar=no);
}
}
}
</script>
</head>
<body>
<input type="button" value="button" name="新窗口打开网站" onclick="WindowOpen()" />
</body>
</html>本人理解 测试过应该是对的
window.open(new2,"_blank",width=400,height=500,menubar=no,toolbar=no); window.open(new2,"_blank",width=400,height=500,"menubar=no,toolbar=no");//你丢双引号了 主要是下面的问题
return new2 //执行到这一行意味着你将会返回不会继续执行本程序块下面语句