為什么點(diǎn)擊按鈕沒(méi)有反應(yīng)呢?能幫我看一下代碼嗎?
<html>
?<head>
? <title> new document </title>?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>??
? <script type="text/javascript">?
? function openWindow()
? {
??? var ask=confirm("確定打開(kāi)新窗口嗎?");// 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
??? if(sak==true)
??? {
????? var www=prompt("請(qǐng)輸入網(wǎng)址:","http://idcbgp.cn/");
??? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
????? if(www)
????? window.open(www,'_blank','width=400,height=500,menubar=no,toolbar=no');
????? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄.
????? else
????? alert("再見(jiàn)!");}
????? else
????? alert("再見(jiàn)!");
? }
???
? </script>
?</head>
?<body>
?? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
2016-08-22
var ask=confirm("確定打開(kāi)新窗口嗎?");// 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
??? if(sak==true)
ask、sak,注意拼寫(xiě)
2016-08-23
<!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 qr = confirm("是否打開(kāi)");
? ? ? ? if(qr==true){
? ? ? ? ? ? var dh=prompt("請(qǐng)輸入網(wǎng)址"," http://idcbgp.cn/");
? ? ? ? ? ? if(dh !=null){
? ? ? ? ? ? ? ? window.open(' http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')
? ? ? }
? ? ? ? }
? ? ? ? }
? ??
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
這是我寫(xiě)的,效果出來(lái)了,可以看一下.你寫(xiě)的有幾個(gè)地方語(yǔ)法錯(cuò)了,你的分號(hào)有兩個(gè)用的是中文的,而且else可以不用寫(xiě)
2016-08-22
首先是修改后的代碼,幾個(gè)問(wèn)題
1、ask!=sak
2、標(biāo)點(diǎn)符號(hào)時(shí)刻注意全角半角,如果覺(jué)得不明顯可以嘗試換一些字體
3、代碼一定要寫(xiě)的好看點(diǎn),不要局限于C以及C++的括號(hào)風(fēng)格,其實(shí)Javascript還是有些不一樣的