第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

對(duì)于輸入對(duì)話框的使用(prompt)有疑問

原先的代碼是醬紫的:

function openWindow(){

? ? ? ? ? var message=confirm("你是否要打開新窗口")

? ? ? ? ? ? ? if(message==true)

? ? ? ? ? ? ? ? { ?var str=prompt("請(qǐng)輸入你要打開的新窗口的網(wǎng)址","http://idcbgp.cn/");

? ? ? ? ? ? ? ? ? ? ? if(str==true)

? ? ? ? ? ? ? ? ? ? ? ?{window.open('http://idcbgp.cn/',width=400,height=500,menubar=no,toolbar=no);}

? ? ? ? ? ? ? ? ? ? ?else() ? {}

? ? ? ? ? ? ? ? }

? ? ? ? ? ? else() ? {}

}

然后問題出來(lái)了,在我在對(duì)話框中點(diǎn)擊確定時(shí),沒有出現(xiàn)慕課網(wǎng)的網(wǎng)頁(yè),而是重新返回到了我學(xué)習(xí)的網(wǎng)頁(yè)。我看了看下邊的評(píng)論,然后修改為if(str)就對(duì)了,但是我還是搞不懂這個(gè)prompt在進(jìn)行判斷時(shí)是如何使用的?

正在回答

2 回答

prompt 返回的是文本輸入框的信息,不是Boolean值,你把它和confirm弄混了,所以prompt的值不能作為if的判斷條件

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

狄狄愛吃魚 提問者

非常感謝!
2017-12-17 回復(fù) 有任何疑惑可以回復(fù)我~
#2

狄狄愛吃魚 提問者

get啦,所以不可以判斷prompt輸入內(nèi)容的真假,謝啦!
2017-12-17 回復(fù) 有任何疑惑可以回復(fù)我~

var str=prompt("請(qǐng)輸入你要打開的新窗口的網(wǎng)址","http://idcbgp.cn/");?//錯(cuò)誤

后面的網(wǎng)址不要填寫,prompt(str1, str2);

str2 是你輸入的網(wǎng)址;

輸入網(wǎng)址點(diǎn)擊確定按鈕,文本框(str2)中的內(nèi)容將作為函數(shù)返回值


我的code

<!DOCTYPE html>

<html>

?<head>

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

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

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

? ? function openWindow(){

? ? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開

? ? ? ? var message = confirm("true and false");

? ? ? ? if(message){

? ? // 通過(guò)輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/

? ? ? ? var score = prompt("請(qǐng)輸入網(wǎng)址:");

? ? //打開的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。

? ? ? ? ? ? window.open(score,"-blank","width=400,height=500");

? ? ? ? }

? ? }

? </script>?

?</head>?

?<body>?

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

?</body>

</html>

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

舉報(bào)

0/150
提交
取消

對(duì)于輸入對(duì)話框的使用(prompt)有疑問

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

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

幫助反饋 APP下載

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

公眾號(hào)

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