最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

怎么能讓prompt僅僅輸入該網(wǎng)址時(shí)才跳轉(zhuǎn)網(wǎng)頁(yè),輸入別的都無(wú)效呢

<!DOCTYPE html>

<html>

?<head>

? <title> new document </title>??

? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?

? <script type="text/javascript">??

function openWindow(){

var a=confirm("是否打開(kāi)?");

if(a==true)

{var b=prompt("確定打開(kāi)的網(wǎng)址","http://yifanck.cn/");if (b!=null){window.open('http://yifanck.cn/','_blank',width=400,height=500);}else{alert("bye");}}

else

{document.write("再見(jiàn)");}

}

</script>?

?</head>?

?<body>?

? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?

?</body>

</html>

但怎么能讓prompt僅僅輸入該網(wǎng)址時(shí)才跳轉(zhuǎn)網(wǎng)頁(yè),輸入別的都無(wú)效呢


正在回答

3 回答

加一個(gè)判斷條件即可,在你的代碼基礎(chǔ)上增減了一些東西:

<!DOCTYPE html>


<html>


?<head>


? <title> new document </title>??


? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?


? <script type="text/javascript">??


function openWindow(){


var a=confirm("是否打開(kāi)?");


if(a==true)

{

? ? var b=prompt("確定打開(kāi)的網(wǎng)址");//可省略慕課網(wǎng)網(wǎng)址

? ? if (b != 'http://yifanck.cn/')

? ? document.write("希望你輸入慕課網(wǎng)網(wǎng)址而不是其他")

? ? else

? ? {

? ? ? ? window.open(a,'_blank',width=400,height=500);

? ? }

? ??

}

else

{

? ? document.write("再見(jiàn),你不希望打開(kāi)新網(wǎng)址");

? ??

}

}


</script>?


?</head>?


?<body>?


? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?


?</body>


</html>


1 回復(fù) 有任何疑惑可以回復(fù)我~
#1

weixin_慕蓋茨5207985 提問(wèn)者

大神請(qǐng)問(wèn)我這么寫(xiě)對(duì)嗎 我把b!=改成了b==,好像就行了,是不是不符合規(guī)則 if(b=="http://yifanck.cn/"){window.open('http://yifanck.cn/','_blank',width=400,height=500);}else{alert("bye");}
2019-02-11 回復(fù) 有任何疑惑可以回復(fù)我~

你最后是不是少打了一個(gè)else語(yǔ)句

0 回復(fù) 有任何疑惑可以回復(fù)我~

如果你寫(xiě)b=="http://yifanck.cn/"的話(huà),那就說(shuō)明你輸入的是慕課網(wǎng)的網(wǎng)址,而你想要的也是成功打開(kāi)手動(dòng)輸入的慕課網(wǎng)網(wǎng)址,這就對(duì)上了呀。反之,當(dāng)b!=時(shí),你唯有輸入除了慕課網(wǎng)網(wǎng)址外的其他東西,后面的這條語(yǔ)句:window.open('http://yifanck.cn/','_blank',width=400,height=500);}else{alert("bye");才會(huì)被執(zhí)行。

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

weixin_慕蓋茨5207985 提問(wèn)者

謝謝!
2019-02-11 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

怎么能讓prompt僅僅輸入該網(wǎng)址時(shí)才跳轉(zhuǎn)網(wǎng)頁(yè),輸入別的都無(wú)效呢

我要回答 關(guān)注問(wèn)題
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)