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