這代碼對嗎?為什么要設置函數(shù)我不理解。
<!DOCTYPE html> <html> <head> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=gbk"/> <script type="text/javascript"> // 新窗口打開時彈出確認框,是否打開 function windiwopen();{ var mywin=confirm("您確認進入新網(wǎng)址嗎??"); if(mywin==true){ var mywi=prompt("請輸入您將要進去的網(wǎng)址:"); if(mywi!=null){ alert("歡迎進入"); window.open('http://idcbgp.cn/','_blank','width=400,height=500th,menubar=no,toolbar=no');} else{ alert("您需要輸入地址哦");} else{ document.write("好吧,您離開了網(wǎng)頁"); } }// 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/ //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。 </script> </head> <body> <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" /> </body> </html>
2017-07-30
<!DOCTYPE html>
?<html>?
?<head>?
?<title> new document </title>
?<meta charset="utf-8">
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>?
? <script type="text/javascript">?
? ?function windiwopen()
? ?{?
? ? var mywin=confirm("您確認進入新網(wǎng)址嗎??");?
? ?if(mywin==true)
? ? { var mywi=prompt("請輸入您將要進去的網(wǎng)址:","http://idcbgp.cn/");?
? ? ? ?if(mywi!=null)
? ? ? ? ? {?
? ? ? ? ? ? alert("歡迎進入");?
? ? ? ? ? window.open('http://idcbgp.cn/','_blank','width=400,height=500th,menubar=no,toolbar=no');
? ? ?}?
? ?else
? ? {?
? ? ? alert("您需要輸入地址哦");
? ? }?
? }
? ?else{?
? ? ? document.write("好吧,您離開了網(wǎng)頁");
? ? ? ?}
? ? ?}
? ? ?</script>
? ? ? </head>?
? ? ? <body>?
? ? ? <input type="button" value="新窗口打開網(wǎng)站" onclick="windiwopen()">?
? ? ? </body>
? ? ? ?</html>
主要是最后的函數(shù)名沒改
2017-07-30
不對,調(diào)用的函數(shù)名是openWindow(),而且在第一個else之后應該再加一個}
像這樣
<!DOCTYPE html>
<html>?
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">?
// 新窗口打開時彈出確認框,是否打開?
function windowopen()
{?
? ? var mywin=confirm("您確認進入新網(wǎng)址嗎??");
if(mywin==true)
{?
? ? var mywi=prompt("請輸入您將要進去的網(wǎng)址:","http://idcbgp.cn/");
? ??
? ? if(mywi!=null){ alert("歡迎進入");
? ? ?window.open('http://idcbgp.cn/','_blank','width=400,height=500th,menubar=no,toolbar=no');}?
else{ alert("您需要輸入地址哦");} }
else{ document.write("好吧,您離開了網(wǎng)頁"); }
}// 通過輸入對話框,確定打開的網(wǎng)址,默認為 http://idcbgp.cn/ //打開的窗口要求,寬400像素,高500像素,無菜單欄、無工具欄。?
</script>?
</head>?
<body>?
<input type="button" value="新窗口打開網(wǎng)站" onclick="windowopen()" />
</body>
</html>