請(qǐng)問(wèn):為什么按取消鍵還是彈出新窗口,而不是彈出alert的內(nèi)容?
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
function openWindow()
{
? ? ?var openorno=confirm("是否打開(kāi)網(wǎng)址?");
? ? ? ? ?if (openorno=true)
? ? ? ? ? ? ?{
? ? ? ? ? ? ?var openwhich=prompt("打開(kāi)網(wǎng)址為:","http://idcbgp.cn/")?
? ? ? ? ? ? ? if (openwhich=null){window.open("openwhich","_blank","width=400,height=500,menubar=no,toolbar=no");}
? ? ? ? ? ? ? else{alert("已關(guān)閉!");}
? ? ? ? ? ? ?}
? ? ? ? ?else{alert("不打開(kāi)網(wǎng)頁(yè)!");}
}
?</script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2017-03-26
?if (openorno=true)改為?if (openorno==true)
if (openwhich=null)改為if (openwhich!=null)
2017-03-25
在第一個(gè)判斷中應(yīng)該是if(openorno==true) , 你少了一個(gè)‘=’號(hào) ? ?因?yàn)閕f是判斷語(yǔ)句 非0即1 ?