我仔細(xì)檢查了符號,沒有錯,可是點(diǎn)擊按鈕沒有任何結(jié)果,求大神解惑
<!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 open=confirm("您要打開新的窗口嗎");
??? if(open==true)
??? {var cart=prompt("請輸入網(wǎng)址","http://idcbgp.cn/");
???? if(cart!=null)
??? {window.open(cart,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');}
??? else{alert("請輸入網(wǎng)址");}
??? }
??? else{alert("結(jié)束");}
??? }
? </script>
?</head>
?<body>
?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
2017-05-21
confirm 后面那個括號是中文的括號,需要修改為英文下的括號
比較 open === true ? 和 cart !== null ?應(yīng)該這樣寫?
其實(shí)這里的open === true 可以直接寫一個 open 就可以了 不用比較,因?yàn)閏onfirm返回的直接是true 或 false ?可以直接給if?