<!DOCTYPE?HTML>
<html>
<head>
<meta?http-equiv="Content-Type"?content="text/html;?charset=utf-8"?/>
<title>close()</title>
??<script?type="text/javascript">
??function?a()
??{
??var?b=confirm("你確定打開慕課嗎?")
??if(b==true)??
??{window.open('http://idcbgp.cn','_blank','width=300,height=200,menubar=no,toolbar=no,')}
else?if(c!=null)
var?c=prompt("請輸入你喜歡的網址:");
{window.open(c,'_blank','width=300,height=200,menubar=no,toolbar=no,')}
else
{alert("真的沒有喜歡的網址嗎?")}
??}
??</script>
</head>
<body>
<input?type=submit??onClick="a()"?value="點我點我">
</body>
</html>
2015-03-04
分享下我的看法吧:
你沒有理解題意,confirm只是詢問用戶是否接受彈出消息窗口,也就是prompt窗口
順著你的思路的話,你的else if語句判斷條件出錯了,應該是else if(b != null)
而且你的else if后面要緊跟花括號啊,你的花括號掉到下一行了,那么就只執(zhí)行了var?c=prompt("請輸入你喜歡的網址:");語句
你在這里強行用else if真是沒必要,因為confirm返回值只有true和false,你已經判斷過為true的情況了,直接else就可以了
5. 代碼縮進格式可以規(guī)范點哦
2015-03-04
我是這么寫的,互相學習
2015-03-02
else if 后面怎么這樣寫