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

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

設(shè)計(jì)有問題嗎?麻煩大家給我指點(diǎn)

<!DOCTYPE html>

<html>

?<head>

? <title> new document </title> ?

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

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

? ??

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


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


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

? ? function openwindow(){

? ? ? ? var openpt=confirm("是否打開新網(wǎng)頁");

? ? ? ? if(openpt==true)

? ? ? ? {var address=prompt("http://yifanck.cn/");

? ? ? ? if(adress!=null){

? ? ? ? ? ? window.open(adress,"_blank",'width=400px,height=500,menubar=no,toolbar=no');

? ? ? ? }

? ? ? ? else

? ? ? ? {

? ? ? ? ? ? alert("結(jié)束");

? ? ? ? }

? ? ? ??

? ? ? ? }else

? ? ? ? alert{"結(jié)束"};

}

? </script>?

?</head>?

?<body>?

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

?</body>

</html>


正在回答

4 回答

那段代碼是在你的代碼的基礎(chǔ)上修改的,經(jīng)測試也能運(yùn)行,如果你也看不懂的話,那再看看我簡化過的代碼,還是在你的基礎(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 openpt=confirm("是否打開新網(wǎng)頁");

? ? ? ? if(openpt==true){

? ? ? ? ? ? var address=prompt("請輸入網(wǎng)址", "http://yifanck.cn");

? ? }if(address!=null){

? ? ? ? ? ? window.open(address,"_blank",'width=400px,height=500,menubar=no,toolbar=no');

? ? ? ? }else{

? ? ? ? ? ? alert("結(jié)束");

? ? ? ? }

? ? }

?</script>?

?</head>?

?<body>?

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

?</body>

</html>

這樣寫的話,不管你是點(diǎn)擊?confirm() 框的取消按鈕,還是點(diǎn)擊?prompt() 框的取消按鈕,都會彈出?alert("結(jié)束") 提示框。還有你說的if同級別的問題,在?openWindow()?這個函數(shù)里,openpt 和?address 是兩個不同的變量,在if() 條件表達(dá)式里,它們自然也不同的,所以這兩個 if() 語句并不是同級別。還有,if(address!=null){} 語句最好不要放在?if(openpt==true){} 語句里,不然當(dāng)你點(diǎn)擊?prompt() 框的取消按鈕后,不會彈出?alert("結(jié)束") 提示框。這不符合你的設(shè)計(jì)。如果非要放便于你自己理解的話,代碼也可以像你原來的那么寫,不過你寫的代碼真的是漏洞百出,寫碼的時候要走點(diǎn)心?。?/p>

<!DOCTYPE html>

<html>

?<head>

? <title> new document </title> ?

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

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

? ??

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


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


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

? ? function openWindow(){

? ? ? ? var openpt=confirm("是否打開新網(wǎng)頁");

? ? ? ? if(openpt==true){

? var address=prompt("http://yifanck.cn/");

? ? ? ? ? ? ? if(address!=null){

? ? ? ? ? ? ? ? ?window.open(address,"_blank",'width=400px,height=500,menubar=no,toolbar=no');

? ? ? ? }else{

? ? ? ? ? ? alert("結(jié)束");

? ? ? ? }

? ? ? ? }else{

? ? ? ? ? ? alert("結(jié)束");

}

}

? </script>?

?</head>?

?<body>?

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

?</body>

</html>

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

你這樣的設(shè)計(jì)師沒問題,可是寫法就有些錯了,你這樣寫按鈕都打不開,這是我在你代碼的基礎(chǔ)上改過的寫法,你對比看看:

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

? ? function openWindow(){

? ? ? ? var openpt=confirm("是否打開新網(wǎng)頁");

? ? ? ? if(openpt==true){

? ? ? ? ? ? var address=prompt("請輸入網(wǎng)址", "http://yifanck.cn");

? ? ? ? }

? ? ? ? if(address!=null){

? ? ? ? ? ? window.open(address,"_blank",'width=400px,height=500,menubar=no,toolbar=no');

? ? ? ? }else if(openpt==false){

? ? ? ? ? ? alert("結(jié)束");

? ? ? ? }else if(address==null){

? ? ? ? ? ? alert("結(jié)束");

? ? ? ? }

? ? }

? </script>?

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

一只特立獨(dú)行的doge

。。哥們,你這我沒看懂啊。。。你的兩個if是同級別的,沒有嵌套,然后你后面兩個elseif也是同級別的,我沒看懂。。能不能解釋一下
2016-04-08 回復(fù) 有任何疑惑可以回復(fù)我~

語法:prompt(str1, str2);

參數(shù)說明:

str1: 要顯示在消息對話框中的文本,不可修改

str2:文本框中的內(nèi)容,可以修改

默認(rèn)的地址應(yīng)該設(shè)置在promptly()中的第二個字符串中

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

var address=prompt("http://yifanck.cn/");改為var address=prompt(”請輸入網(wǎng)址“,"http://yifanck.cn/");


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

舉報(bào)

0/150
提交
取消

設(shè)計(jì)有問題嗎?麻煩大家給我指點(diǎn)

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

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

幫助反饋 APP下載

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

公眾號

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