不用true判断pro点取消弹出再见!
if(pro){ window.open(pro,'_blank','width=400,height=500,menubar=no,toolbar=no'); }else if(!pro){ alert("Goodbye!"); }
pro判断仅限对确定与取消的操作判断,与内容是否真或空无关,所以加上判断非空或空不起作用,当输入内容为空依然会打开一个空的页面
2015-01-12
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script type="text/javascript">
function openWindow () {
var con=("是否要打开新窗口?");
if (con) {
var pro=prompt("请输入您要打开的网址","http://www.imooc.com");
if (pro) {
window.open(pro,'_blank','width=400,height=500,menubar=no,toolbar=no');
}else{
alert("GoodBye!");
}
}else{
alert("GoodBye too!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
举报