求解為什么沒成功?
<!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 open=confirm("是否新建網(wǎng)頁?");
{var url=prompt("通過輸入對(duì)話框,確定打開的網(wǎng)址"," http://idcbgp.cn");
if(url!=null)
{window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');}
else
{alert("再見!");}
}? ?
else
{alert("再見!");}
}
? </script>
?</head>
?<body>
?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />
?</body>
</html>
2016-07-27
<!DOCTYPE html>
<html>
?<head>
? <title> new document </title> ?
? <meta http-equiv="Content-Type" content="text/html; charset=gbk2312"/> ??
<script type="text/javascript"> ?
function openWindow()
{
var opena=confirm("是否新建網(wǎng)頁?");
? ? ? ? ? ?if(opena==true)
? { ?
? var url=prompt("通過輸入對(duì)話框,確定打開的網(wǎng)址","");
? if(url!=null&&name!="")
? {
? ? ? ? ? ? window.open(url,"target= _blank","width=400px,height=500px,menubar=no,toolbar=no");
? ? }
else
{
alert("再見");
}
}
else
{alert("再見");
}
}
? </script>?
?</head>?
?<body>?
? ? ? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
少了加粗部分是上的一個(gè)}
2016-07-27
<!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 open=confirm("是否新建網(wǎng)頁?");
//加入一個(gè)if判斷語句
if(open==true)
{var url=prompt("通過輸入對(duì)話框,確定打開的網(wǎng)址"," http://idcbgp.cn");
if(url!=null)
{window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');}
else
{alert("再見!");}
}? ?
else
{alert("再見!");}
}
? </script>?
?</head>?
?<body>?
?? ?? <input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>
2016-07-27
去掉多余的大括號(hào),和最后多余的else就行了
<!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 open=confirm("是否新建網(wǎng)頁?");
? var url=prompt("通過輸入對(duì)話框,確定打開的網(wǎng)址"," http://idcbgp.cn");
if(url!=null)
{window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');}
else
{alert("再見!");}
</script>?
?</head>?
?<body>?
?<input type="button" value="新窗口打開網(wǎng)站" onclick="openWindow()" />?
?</body>
</html>