大神們,錯在哪?為什么警告對話框出不來?。。
<!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 boss=confirm("是否要打開新頁面?");
? ? if ?(boss==true){var shabi=prompt("請輸入網址:","http://www.xianlaiwan.cn");
? ? if(shabi="http://www.xianlaiwan.cn"){
? ? ? ? window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,menubar=no,toolbar=no');}
? ? if ? ?else(shabi!=null){alert("再見!");}
? ? }
else { alert("再見!");}
}
? ? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
? ? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
? ??
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>
2016-08-24
? ? ? ? var boss=confirm("是否要打開新頁面?");
? ? if ?(boss==true){var shabi=prompt("請輸入網址:","http://www.xianlaiwan.cn");
? ? if(shabi=="http://www.xianlaiwan.cn"){
? ? ? ? window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,menubar=no,toolbar=no');}
? ? else {alert("再見!");}
? ? }
else { alert("再見!");}
}
2016-08-24
if(shabi="http://www.xianlaiwan.cn")中的判斷至少是"=="吧,或者用equals方法(沒驗證過)。
?if ? ?else是什么鬼,只見過else if。
2016-08-24
if(shabi="http://www.xianlaiwan.cn")? 改成?if(shabi=="http://www.xianlaiwan.cn"),?2個等號,不是一個等號.
2016-08-24
你最后一組if(){}else寫的有問題