我這樣理解有錯嗎?
? ?function openWindow(){
var name
var open
name=confirm("是否打開")
open=prompt("確定打開網址"," http://www.xianlaiwan.cn/")
if (name==true){
? ? alert(open);if (open!==null){window.open(url,'_blank','width=400px','height=500px','menubar=no','toolbar=no')}
? ? else{alert("沒有輸入喔")}
}
else{alert("thank you");}}
2016-08-19
請把if(name==true)放在"open=prompt(......)"語句前面。邏輯是:1.先判斷是否打開,如果點“確定”則name=true;2.當name==true的時候,再執行open=prompt("確定打開網址"," http://www.xianlaiwan.cn/"),讓用戶輸入網址。請注意'width=400px','height=500px','menubar=no','toolbar=no'應改為‘width=400px,height=500px,menubar=no,toolbar=no',作為window.opne的第三個參數。
2016-08-19
其實我感覺沒什么錯誤,只是在alert(open);這一句會有額外的提示信息,在使用的過程中操作較為繁瑣一些,邏輯上沒什么錯誤。
2016-08-19
你的兩個彈出框是一起執行的,他們兩個不應該是有層級關系的么,這樣的話,當你彈出“是否打開”彈出框,無論你點確定或者取消,都會執行下一個彈出框的吧。
2016-08-19
寫兩層嵌套的if干嘛,,一層就可以了
2016-08-19
錯了,這里不需要?alert(open),open=prompt("確定打開網址"," http://www.xianlaiwan.cn/"),這一句就是選擇確定輸入的網站