這樣寫有錯(cuò)嗎?為什么運(yù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=confirm("確定打開(kāi)窗口?") ? ? ? ?// 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? ? ? if(open==ture){
? ? ? ? ? ? var URL=prompt("請(qǐng)輸入網(wǎng)址","http://idcbgp.cn/") ? ?// 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? ? ? ? ? if(prompt!=null){
? ? ? ? ? ?window.open("http://idcbgp.cn/","_blank","width=400,height=500,menubar=no,toolbar=no,scrollbars=no")} ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ? ? ? ? ? else{alert("bye!")} }
? ? ? ? ? ??
? ? ? ? ?else{alert("bye!")}
? ? ? ? ?} ? ? ?
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2015-08-03
2015-08-05
javascript語(yǔ)句末尾都沒(méi)加分號(hào);
windowopen("http://idcbgp.cn/","_blank","width=400,height=500,menubar=no,toolbar=no,scrollbars=no");
這一句只能打開(kāi)”http://idcbgp.cn/“,應(yīng)該改為:
windowopen(URL,"_blank","width=400,height=500,menubar=no,toolbar=no,scrollbars=no");
if(){
}
else{
}
你的else語(yǔ)句都放在了if語(yǔ)句的大括號(hào)里了哦。。
標(biāo)點(diǎn)符號(hào)一定記得換成英文輸入?。?!標(biāo)點(diǎn)符號(hào)一定記得換成英文輸入?。?!標(biāo)點(diǎn)符號(hào)一定記得換成英文輸入?。。。ㄖ匾氖虑檎f(shuō)三遍)不然后面找問(wèn)題,會(huì)找到哭的~
2015-08-03
ture改成true還是不行
2015-08-03
這里是true,不是ture
這里逗號(hào)錯(cuò)了,敲成中文的啦,改成英文的
修改后的代碼