描述
js控制浏览器窗口弹出、警告框、确认框
代码
function fun1(){
alert("喜欢我");
}
function fun2(){
var bo = confirm("确定要关闭吗?");
if(bo){
window.close();
}else{
//window.open("guanggao.html","_self");
window.open("guanggao.html","_blank","height=200,width=200")
}
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="js/index.js"></script>
</head>
<body >
window对象<br/>
<input type="button" value="测试alert" onclick="fun1()" />
<input type="button" value="测试confirm" onclick="fun2()" />
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body style="background-color: aqua;">
广告
</body>
</html>
运行效果