課程
/前端開發
/JavaScript
/JavaScript入門篇
我的代碼不知道哪里出錯了,請幫我改改,謝謝了!代碼如下:
2016-11-15
源自:JavaScript入門篇 2-7
正在回答
function?openWindow()//創建函數,響應按鈕點擊事件 ????{ ????????//1點擊新窗口打開網站按鈕時彈出確認框(confirm) ????????var?mywin=confirm("確定打開新網頁?"); ????????if(mywin==true)//判斷是否點擊確認 ????????{ ????????????//2、通過輸入對話框,確定打開的網址,默認為?http://www.xianlaiwan.cn/ ????????????var?Wopen=prompt("請輸入一個網址","http://www.xianlaiwan.cn/"); ????????????if(Wopen!=null)//點擊確認 ????????????{ ????????????????//打開寬400像素,高500像素,無菜單欄、無工具欄的窗口 ????????????????window.open(Wopen,'_blank','width=400,height=500,menubar=no,toolbar=no'); ????????????} ????????} ????}
慕粉4340077 提問者
<!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?isopen?=?confirm('確認新建窗口打開網頁'); ????if(isopen?==true){ ?????????//?通過輸入對話框,確定打開的網址,默認為?http://www.xianlaiwan.cn/ ????????var?input?=?prompt('請輸入網址確認打開'); ????????if(input?!=?null){ ?????????????//打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 ?????????????window.open(input,"_blank",'width=400,height=500,menubar=no,toolbar=no'); ???????????? ????????} ???????? ????} ???? ???? ????} ??? ??? ???? ???? ??</script>? ?</head>? ?<body>? ??<input?type="button"?value="新窗口打開網站"?onclick="openWindow()"?/>? ?</body> </html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
</head>
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ??
function test1(){ ? ?var testif = confirm("是否打開新窗口?"); ? ?var ifsure = prompt("請輸入是和否"); ? ?if(testif == true){ ? ? ? ?if(ifsure!=null){ ? ? ? ? ? ?window.open('http://www.xianlaiwan.cn/', ? ? ? ? ? ? ? ?'_blank', ? ? ? ? ? ? ? ?'width=400,height=500,menubar=no,toolbar=no,status=no,scrollbars=yes' ? ? ? ? ? ?); ? ? ? ?} ? ?}}
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="test1()" />?
?</body>
</html>
? ?function openWindow(){
? ?var msg =confirm("是否打開新窗口?");
? ? ? ? ? ?if(msg==true){
? ? ? ? ? ? ? ?var url= prompt("請輸入是和否");
? ? ? ? ? ? ? ?if(url=="是"){
? ? ? ? ? ? ? ? ? ?window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500');
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
舉報
JavaScript做為一名Web工程師的必備技術,本教程讓您快速入門
1 回答JS入門篇的編程挑戰
2 回答javascript入門,編程挑戰的問題
7 回答JavaScript入門篇 4-1編程挑戰,幫看看為什么我的運行不了?
1 回答js入門篇最后一個編程挑戰
1 回答關于JavaScript入門第四章編程挑戰
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-11-15
2016-11-15
2016-11-15
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
</head>
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ??
function test1(){
? ?var testif = confirm("是否打開新窗口?");
? ?var ifsure = prompt("請輸入是和否");
? ?if(testif == true){
? ? ? ?if(ifsure!=null){
? ? ? ? ? ?window.open('http://www.xianlaiwan.cn/',
? ? ? ? ? ? ? ?'_blank',
? ? ? ? ? ? ? ?'width=400,height=500,menubar=no,toolbar=no,status=no,scrollbars=yes'
? ? ? ? ? ?);
? ? ? ?}
? ?}
}
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="test1()" />?
?</body>
</html>
2016-11-15
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>無標題文檔</title>
</head>
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> ??
? <script type="text/javascript"> ?
? ??
? ?function openWindow(){
? ?var msg =confirm("是否打開新窗口?");
? ? ? ? ? ?if(msg==true){
? ? ? ? ? ? ? ?var url= prompt("請輸入是和否");
? ? ? ? ? ? ? ?if(url=="是"){
? ? ? ? ? ? ? ? ? ?window.open('http://www.xianlaiwan.cn','_blank','width=400,height=500');
? ? ? ? ? ? ? ?}
? ? ? ? ? ?}
? ? ? ?}
? ??
? </script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網站" onclick="openWindow()" />?
?</body>
</html>