課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
這個(gè)代碼怎么寫
2016-12-01
源自:JavaScript入門篇 2-7
正在回答
<!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 ans=confirm("確認(rèn)打開嗎?");
? ? if(ans==true){
? ? ? ?window.open('http://idcbgp.cn', '_blank', 'width=400px, height=500px,menubar=no,toolbar=no');
? ? }else{}
? ? }
? ??</script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
穿越地平線tkd 提問者
不二館四葉
不二是兔子 回復(fù) 不二館四葉
1、新窗口打開時(shí)彈出確認(rèn)框,是否打開
要確認(rèn),所以用confirm函數(shù),確定是true,取消是false,通過返回值判斷
var [變量名]=confirm("隨便寫,比如你確定打開嗎?");
然后通過判斷這個(gè)變量是true還是false,false就是不打開,不用寫。在條件為true的語句段里寫下面的要求
if(變量==true) {在這里寫后面的要求}????
else????{alert('不打開算了');}
2、通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
3、打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
這兩個(gè)要求是寫在一個(gè)句子里的,就是window.open()函數(shù)
如果不會(huì)看下之前的教程:
window.open('http://idcbgp.cn', '_blank', 'width=400px, height=500px,menubar=no,toolbar=no');
依次對(duì)應(yīng) 網(wǎng)址;新窗口;寬度;高度;菜單欄;工具欄
這一句是寫在上面的 if 后的花括號(hào){}里
希望能幫到你
<script type="text/javascript"> ?
? ? ? ? var flag=confirm("是否點(diǎn)擊了確定?");
? ? ? ? if(flag==true){
? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ?}else{
? ? ? ? }
</script>?
舉報(bào)
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
5 回答這個(gè)代碼怎么寫?
4 回答這個(gè)問題的代碼怎么寫呀
2 回答怎么寫script代碼?
2 回答怎么完善這個(gè)代碼?
3 回答這個(gè)代碼怎么錯(cuò)了
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號(hào)-11 京公網(wǎng)安備11010802030151號(hào)
購課補(bǔ)貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動(dòng)學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號(hào)
2016-12-01
<!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 ans=confirm("確認(rèn)打開嗎?");
? ? if(ans==true){
? ? ? ?window.open('http://idcbgp.cn', '_blank', 'width=400px, height=500px,menubar=no,toolbar=no');
? ? }else{}
? ? }
? ??</script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-12-01
1、新窗口打開時(shí)彈出確認(rèn)框,是否打開
要確認(rèn),所以用confirm函數(shù),確定是true,取消是false,通過返回值判斷
var [變量名]=confirm("隨便寫,比如你確定打開嗎?");
然后通過判斷這個(gè)變量是true還是false,false就是不打開,不用寫。在條件為true的語句段里寫下面的要求
if(變量==true) {在這里寫后面的要求}????
else????{alert('不打開算了');}
2、通過輸入對(duì)話框,確定打開的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
3、打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。
這兩個(gè)要求是寫在一個(gè)句子里的,就是window.open()函數(shù)
如果不會(huì)看下之前的教程:
window.open('http://idcbgp.cn', '_blank', 'width=400px, height=500px,menubar=no,toolbar=no');
依次對(duì)應(yīng) 網(wǎng)址;新窗口;寬度;高度;菜單欄;工具欄
這一句是寫在上面的 if 后的花括號(hào){}里
希望能幫到你
2016-12-01
<script type="text/javascript"> ?
? ? function openWindow(){
? ? ? ? var flag=confirm("是否點(diǎn)擊了確定?");
? ? ? ? if(flag==true){
? ? ? ? ? ? window.open('http://idcbgp.cn','_blank','width=400,height=500,menubar=no,toolbar=no');
? ? ? ? ?}else{
? ? ? ? }
? ? ? ? }
</script>?