prompt?
function openWindow()
?{
? ? ?var click=confirm("確定打開新窗口?");
? ? ?if(click==true)
? ? ?{
? ? ? ? var talk=prompt("確定打開的網(wǎng)址:");
? ? ? ? if(talk!=null)
? ? ? ? {
? ? ? ? ? ? window.open('http://idcbgp.cn','_block','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? }
? ? ? ? else
? ? ? ? {
? ? ? ? ? ? alert("去吧,皮卡丘");
? ? ? ? }
? ? ?}
? ? ?else
? ? ?{
? ? ? ? ?alert("翻滾吧,牛寶寶");
? ? ?}
}
這里prompt下面的? if(talk!=null)是說如果talk不為空就打開新窗口,那為什么我沒有在文本框里輸入信息時(shí),還是可以打開新窗口呢?
2016-04-08
在文本框里沒有輸入那么點(diǎn)擊確定talk="",不是等于null啊,然后就會(huì)打開一個(gè)空白的窗口。只有點(diǎn)擊取消的時(shí)候talk=null
2016-04-26
function openWindow()
{
? ?var one=confirm("是否打開?");
? ?if(one==true)
? ?{
? ? ?var two=prompt("請(qǐng)輸入打開的網(wǎng)址","http://cham.pe.hu/");?
? ? ?if(two!=null)
? ? ?{
? ? ? ? window.open( two,'_blank',width=400,height=500);
? ? ?}
? ?}
}
2016-04-08
不輸入不代表null,只有點(diǎn)擊取消才是返回null
2016-04-08
不輸入就可以打開空的窗口,系統(tǒng)默認(rèn)