這段代碼錯(cuò)誤在哪里?
無論最后是點(diǎn)擊“是”還是“取消”,結(jié)果都是執(zhí)行“else”里的內(nèi)容
<!DOCTYPE html>
<html>
<head>
<title>練習(xí)</title>
<meta charset="utf-8">
</head>
<script type="text/javascript">
function openwindow()
{
var a=confirm("是否打開網(wǎng)址");
if (a==true)?
? {var q=prompt("確定打開的網(wǎng)址","https://www.zhihu.com/");
? ? ? if (q==true)?
? {window.open("https://www.zhihu.com/","_blank","width=400px,height=500px,top=100px,left=100px");}
? ? ? else
? {alert("你選擇了取消!");}
? ?}
}
</script>
<body>
<input type="button" name="button" value="點(diǎn)擊選擇是否打開" onclick="openwindow()"/>
</body>
</html>
2019-05-11