首页 > 应用开发 > > confirm 为啥我点了取消还是打开了窗口?
<!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 creatNewWindow=confirm("是否需要百度?");
// 新窗口打开时弹出确认框,是否打开
if(creatNewWindow=true)
{
window.open('https://www.baidu.com/','_blank');
}
// 通过输入对话框,确定打开的网址,默认为 http://
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else{
document.write("不跟你玩了!");
alert("给你一个大嘴巴子!");
}}
</script>
</head>
<body>
<input type="button" value="百度一下" onClick="openWindow()">
</body>
</html>
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/2557/viewspace-3160903/ ,如需转载,请注明出处,否则将追究法律责任。