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