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

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

大神幫忙找下錯(cuò)誤,自己掌握的太少了~

<!DOCTYPE html>

<html>

?<head>

? <title> new document </title> ?

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

?

?</head>?

?<body>?

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

<script type="text/javascript"> ?

? ? function openWindow()

? ? {

? ? ? ? var su=confirm("是否打開?");

? ? ? ? if(su==true)

? ? ? ? {

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

? ? ? ? ? ?if(a!=null)

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

? ? ? ? ? ?else

? ? ? ? ? ? window.open('http://yifanck.cn','_blank','width=400,height=500,toolbar=no,menubar=no')

? ? ? ? }

}

? ??

? ??

? </script>

?</body>

</html>


正在回答

2 回答

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

這里中間差個(gè)逗號(hào)

var?a=prompt("請(qǐng)輸入網(wǎng)址"?,"http://yifanck.cn");
window.open('a','_blank','width=400,height=500,toolbar=no,menubar=no');

這一句a是不需要加引號(hào),加引號(hào)是字符串了

window.open(a,'_blank','width=400,height=500,toolbar=no,menubar=no');

這里其實(shí)else后面執(zhí)行的操作應(yīng)該不是打開網(wǎng)站,可以省略或者彈個(gè)框。

修改后的代碼

<script?type="text/javascript">??
????function?openWindow()
????{
????????var?su=confirm("是否打開?");
????????if(su==true)
????????{
???????????var?a=prompt("請(qǐng)輸入網(wǎng)址"?,"http://yifanck.cn");
???????????if(a!=null)
??????????????window.open(a,'_blank','width=400,height=500,toolbar=no,menubar=no');
???????????else
????????????alert("bye!");
????????}
????}
</script>


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

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

? ? ? ? ? ?if(a!=null)

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

? ? ? ? ? ?else

? ? ? ? ? ? window.open('http://yifanck.cn','_blank','width=400,height=500,toolbar=no,menubar=no')

這個(gè)地方是否可以不用if判斷?因?yàn)閜rompt返回的是文本框中的內(nèi)容,既然有默認(rèn)值那返回肯定是默認(rèn)的地址,可以直接寫成window.open('a','_blank','....');這樣嗎?

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

舉報(bào)

0/150
提交
取消
JavaScript入門篇
  • 參與學(xué)習(xí)       741543    人
  • 解答問(wèn)題       9869    個(gè)

JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門

進(jìn)入課程

大神幫忙找下錯(cuò)誤,自己掌握的太少了~

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

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

幫助反饋 APP下載

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

公眾號(hào)

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