問(wèn)一下哪里錯(cuò)了,彈不出來(lái)
<!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)新窗口");
? ? if (open==true)
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? {var url==prompt("請(qǐng)輸入網(wǎng)址")
? ? if (url!null)
? ? {window.open(url,'_blank','width=400,height=500')
? ? else
? ? {window.open('http://idcbgp.cn','_blank','width=400,height=500')
? ? }
? ? }
? ? }
? ? }
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2018-10-29
1,url后面應(yīng)該是一個(gè)等號(hào),
2,好像是if的嵌套導(dǎo)致的問(wèn)題
3,第二個(gè)if少一個(gè) 右大括號(hào) }
希望能幫助你!
2018-10-29
? <script type="text/javascript">??
? ? function openWindow(){
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? var ifopen=confirm("是否確認(rèn)打開(kāi)窗口?")
? ? if(ifopen==true)
? ? ? ? {
? ? ? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? ? ? ? ? var url=prompt("請(qǐng)輸入網(wǎng)址,默認(rèn)為慕課網(wǎng)")
? ? ? ? ? ? if(url==''){
? ? ? ? ? ? ? ? url="http://idcbgp.cn/"
? ? ? ? ? ? }
? ? ? ? ? ? window.open(url,'_blank','width=400,height=500','menubar=no','toolbar=no');
? ? ? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ? ? ? }
? ? }
? </script>?
僅供參考