<script type="text/javascript"> function openWindow(){ var message=confirm("是否打开对话框"); if (message=="true") { window.open('http://www.imooc.com/', 'width=400','height=500',menubar=no,toolbar=no} } else {alert("再见!");} } </script></head><body><input type="button" value="新窗口打开网站" onclick="openWindow()" /></body>
2 回答
已采纳
西兰花伟大炮
TA贡献376条经验 获得超318个赞
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>Document</title>
</head>
<body>
<input type="button" value="打开新窗口" onclick="openWindow()"/>
<script>
function openWindow(){
var message = confirm("是否打开新窗口?");
if(message == true){
window.open("http://www.imooc.com");
}else{
alert("再见!");
}
};
</script>
</body>
</html>写成这样就可以了
添加回答
举报
0/150
提交
取消
