為啥打不開網(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 str=confirm("是否打開新窗口");
? ? ? ? if(str==ture)
? ? ? ? {window.open('http://idcbgp.cn','width=400,heigth=500,menubar=no,toolbar=no');}
? ? ? ? else;
? ? }
? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
? ? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2018-10-20
首先你單詞拼錯(cuò)了是true
如圖所示 控制臺報(bào)錯(cuò)true是不明確的數(shù)據(jù)類型瀏覽器不識別
把變量的值輸出在控制臺為true 相當(dāng)于布爾型數(shù)據(jù)類型值為1 所以正確的應(yīng)該是這么寫
希望對樓主有幫助