為什么這個網址打不開?
function openWindow()
??? {
??? var box1=confirm("是否打開")// 新窗口打開時彈出確認框,是否打開
??? if(box1==true)
{
??? var box2
??? box2=prompt("打開以下網址:","http://www.xianlaiwan.cn/")// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
??? if(box2==true)
??? {
??? window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,,menubar=no,toolbar=no')//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
??? }
??? else{alert("88");}
}
else{alert("88");}
??? }
2016-06-11
? var box2
??? box2=prompt("打開以下網址:","http://www.xianlaiwan.cn/")// 通過輸入對話框,確定打開的網址,默認為 http://www.xianlaiwan.cn/
??? if(box2==true)
??? {
??? window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500,,menubar=no,toolbar=no')//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。//出現兩個逗號
??? }
? ? 這里box2返回的是輸入的地址不是boolean值,所以后面這邊? if(box2==true)判斷是不對的。所以打不開,
還有這里,,出現了兩個逗號,我不能確定可不可以這么寫。
2016-06-13
if (box2 != null)
2016-06-11
window.open 雙引號可以
你可以跟著這個改改 ?我昨天也碰到了
2016-06-11
<!DOCTYPE html>
<title>瀏覽器對象</title>?
? <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> ??
?<script type="text/javascript"> ?
function openWindon(){?
if(confirm("確定打開新窗口嗎?")){
var url = prompt("請輸入一個網址","http://www.xianlaiwan.cn/"); ?
window.open( url,"_blank","toolbar=no, menubar=no, scrollbars=yes, ?width=400, height=400");
}
} ?
?</script>
?</head>?
?<body>
? <input type="button" value="新窗口打開網站" onclick="openWindon()" />?
</body>
</html>