這個(gè)代碼正確嗎?
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title>??
? <meta http-equiv="Content-Type" content="text/html; charset=gbk"/>? ?
? <script type="text/javascript">??
? ? function openwindow(){
? ? ? ? ?if (confirm("打開(kāi)新窗口")) {
? ? ? ?window.open('http//idcbgp.cn,''_blank','height=500,width=400','tolbar=no','menu bar=no',);
? ? ? ?else{
? ? ? ? ? ? ? alert("你選擇了取消");
? ? ? ? ? }
? }?
? ??
? ? // 新窗口打開(kāi)時(shí)彈出確認(rèn)框,是否打開(kāi)
? ? // 通過(guò)輸入對(duì)話框,確定打開(kāi)的網(wǎng)址,默認(rèn)為 http://idcbgp.cn/
? ? //打開(kāi)的窗口要求,寬400像素,高500像素,無(wú)菜單欄、無(wú)工具欄。? ??
? </script>?
?</head>?
?<body>?
? <input type="button" value="新窗口打開(kāi)網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
因?yàn)闊o(wú)法驗(yàn)證,所以不知道有沒(méi)有碼對(duì)。
2018-12-28
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>編程練習(xí)</title>
<script type="text/javascript">
function rec()
{
var open=confirm("是否需要在新的窗口打開(kāi)目標(biāo)網(wǎng)站?");
if(open==true)
{
var url=prompt("請(qǐng)鍵入您即將在新窗口打開(kāi)的網(wǎng)站網(wǎng)址:"," http://idcbgp.cn/");
if(url!=null)
{
window.open(url,'_blank','width=400,height=500');
}
else
{
alert("再見(jiàn)");
}
}
else
{
var url=prompt("請(qǐng)鍵入您即將在本窗口打開(kāi)的網(wǎng)站網(wǎng)址:"," http://idcbgp.cn/");
if(url!=null)
{
window.open(url,'width=400,height=500');
}
}
}
</script>
</head>
<body>
<input type="button" name="button" onclick="rec()" value="跳轉(zhuǎn)到其他網(wǎng)站"/>
</body>
</html>
2018-12-28
你的confirm用法和前面課上所講的用法不一樣
2018-12-27
不對(duì),無(wú)法運(yùn)行