正解在這里
<!DOCTYPE HTML>
<html>
<head>
??? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
??? <title>prompt</title>
??? <script type="text/javascript">
??? function openWindow() {
??????? var flag = confirm("是否打開新窗口?");
??????? // 新窗口打開時彈出確認框,是否打開
??????? if(flag) {
??????????? var url = prompt("請確認網址", "http://www.xianlaiwan.cn/");
??????????? // 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
??????????? if(url != null) {
??????????????? window.open(url, '_blank', 'width=400,height=500,menubar=no,toolbar=no');
??????????????? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
??????????? } else {
??????????????? window.close();
??????????? }
??????? }
??? }
??? </script>
</head>
<body>
??? <input type="button" value="新窗口打開網站" onclick="openWindow()" /> </body>
</html>
2018-06-19
if( ),括號里不是加條件么?flag定義的是變量吧,求解
2018-06-12
你少了一個else判斷吧