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

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

如何實(shí)現(xiàn)輸入為空時(shí)跳轉(zhuǎn)默認(rèn)網(wǎng)頁?我代碼prompt里的取消為何會跳轉(zhuǎn)到其他網(wǎng)頁?

<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript"> ?
?? ?
??? // 新窗口打開時(shí)彈出確認(rèn)框,是否打開
??? function openWindow(){
??????? var openw=confirm("是否打開窗口?");
??????? if(openw==true){
??????????? var weburl=prompt("請輸入網(wǎng)址:","http://idcbgp.cn/");
??????????? if(weburl!=null){
??????????????? openw=window.open(weburl,'_blank','width=400,height=500,menubar=no,scrollbars=no');
??????????? }
??????????? else{
??????????????? openw=window.open('http://idcbgp.cn/','_blank','width=400,height=500,menubar=no,scrollbars=no');
??????????? }
??????? }
??????? else{
??????????? alert("ByeBye!");
??????? }
??? }
??? // 通過輸入對話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/

??? //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
?? ?
?? ?
? </script>
?</head>
?<body>
?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>

正在回答

3 回答

首先,因?yàn)槟膒rompt第二參數(shù)已存在路徑,所以即使您不輸入,它也會默認(rèn)輸入已存在,其次當(dāng)取消時(shí),返回值為null,代碼將直接跳轉(zhuǎn)到此行https://img1.sycdn.imooc.com//5b764349000133c207920062.jpg,所以將會跳轉(zhuǎn)到您輸入的其他網(wǎng)頁。

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

var val=prompt();

if(val==null)

window.open();

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

輸入空的時(shí)候返回的不是null,點(diǎn)取消返回的才是null

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

katte

直接點(diǎn)擊確定,由于你沒有輸入任何內(nèi)容,獲取內(nèi)容的獲取的就是'',prompt函數(shù)返回值為'',于是name被賦值為'', '' != null。
2018-08-16 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

如何實(shí)現(xiàn)輸入為空時(shí)跳轉(zhuǎn)默認(rèn)網(wǎng)頁?我代碼prompt里的取消為何會跳轉(zhuǎn)到其他網(wǎng)頁?

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

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

幫助反饋 APP下載

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

公眾號

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