關(guān)于代碼的筆記記錄!
<!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=prompt("是否打開(kāi)下列網(wǎng)站","http://idcbgp.cn/");
???? if(_open!=null)
???? {
???????? window.open(_open,"_blank","width=400,hight=500,toolbar=no");
???? }
? }// 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
??? // 通過(guò)輸入對(duì)話(huà)框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
??? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
?? ?
?? ?
? </script>
?</head>
?<body>
?? ?? <input type="button" value="點(diǎn)擊打開(kāi)網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
上述代碼正確,記錄一下我的錯(cuò)誤位置
第一個(gè)錯(cuò)誤:網(wǎng)頁(yè)的冒號(hào)直接復(fù)制粘貼導(dǎo)致網(wǎng)頁(yè)錯(cuò)誤
第二個(gè)錯(cuò)誤:window。open()里面第一個(gè)參數(shù)如果直接為網(wǎng)頁(yè)地址,則不需要再添加雙引號(hào)or單引號(hào)
以上
2020-02-13
用confirm邏輯分明一些