彈出第一個詢問框,點擊取消為什么還會自動跳轉(zhuǎn)網(wǎng)頁。 求解答謝謝
<!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 dakai=confirm("是否打開該網(wǎng)頁?");
? ? ? ?if (dakai==true)
? ? ?{var b=prompt("確定打開的網(wǎng)址","http://idcbgp.cn/");
? ? ?if(b=true)
? ? ?{window.open('http://idcbgp.cn/','_blank',width=400,height=500)}
? ?else
? ?{document.write("拜拜");}
? ? }
? ? else
? ?{document.write("拜拜");}
? ? }
? ? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2019-02-12
業(yè)務(wù)邏輯上出問題了,你應(yīng)該把prmpot()獲取到的 Boolean值的判斷寫在confirm()的判斷內(nèi),