if(url!=null)為什么不能寫成if(url==true)
function openWindow(){
? ? var open=confirm("確認(rèn)新建窗口打開網(wǎng)站嗎?")
? ? if(open==true)
? ? ? ? {var url=prompt("通過輸入對(duì)話框,確定打開的網(wǎng)址","http://idcbgp.cn");
? ? ? ? ? ? if(url!=null){window.open(url,"_blank","width=400,height=500,menubar=no,toolbar=no");}
? ? ? ? ? ? else{alert("再見");}
? ? ? ? }
? ? ? ? ? ? else{alert("bay");}
? ? }
2016-04-28
url并不是Boolean型~
2016-04-28
if(url!=null)可以寫成if(url),而不是if(url==true)。url并不指向True
2016-04-28
prompt("……","……")和confirm("……")不一樣,
confirm("")只需要確認(rèn)”是“或者”否“;
而prompt("……","……")需要判斷你輸入的內(nèi)容是否為空,
2016-04-28
!=null ?說明只要有輸入就可以了 ?而當(dāng)你輸入一堆網(wǎng)址的時(shí)候 ?不一定是?== true
2016-04-28
null不等于false,所以它的反義不是true
2016-04-28
http://www.c-point.com/javascript_tutorial/jsgrpComparison.htm?這上面解釋的很清楚
2016-04-28
==true時(shí)不可以構(gòu)成判斷