剛寫完的,參考下!
<!DOCTYPE html>
<html>
<head>
?? ?<meta charset="utf-8">
?? ?<meta http-equiv="X-UA-Compatible" content="IE=edge">
?? ?<title>慕課練習(xí)6</title>
?? ?<link rel="stylesheet" href="">
?? ?? <script type="text/javascript"> ?
??? function openWindow(){
??? var open=confirm("是否要打開?");
??? if(open==true){
??????? var score=prompt("確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/:");
??????? if(score==""){
?????? ??? ? window.open("http://idcbgp.cn/","_blank","width=400,heigth=500,menubar=no,toolbar=no,scrollbars=yes");
??????? }
??????? else{
?????? ??? ??? ? alert("抱歉!,打擾到你了,再見。");
??????? }
??? }
??? else{
??????? alert("打擾了,再見!");
??? }
?????? ?
??? }
??? // 新窗口打開時彈出確認(rèn)框,是否打開
??? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
?? ?
?? ?
? </script>
</head>
<body>
?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /> ?? ?
</body>
</html>
2019-05-04
感覺既然confirm返回值是不是true就是false
那直接if(open)應(yīng)該就可以吧