慕瓜4488895
2018-05-28 11:45
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
function openWindow()
{
var open=confirm("确定打开新的窗口");
if(open=true)
{
var url=prompt("打开输入的网址","www.baidu.com");
if (url!=null)
{
window.open(url"_blank");
}
else
{
alert("88");
}
}
else
{
alert("再见");
}
}
</script>
</head>
<body>
<form>
<input type="button" value="新窗口打开网站" onclick="openWindow()">
</form>
</html>
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
function openWindow()
{
var open=confirm("确定打开新的窗口");
if(open=true)
{
var url=prompt("打开输入的网址","www.baidu.com");
if (url!=null)
{
window.open(url"_blank");
}
else if
{
alert("88");
}
else
{
alert("再见");
}
}
</script>
</head>
<body>
<form>
<input type="button" value="新窗口打开网站" onclick="openWindow()">
</form>
</html>
你的第二个else应该是else if,后面还多写了一个}
JavaScript入门篇
739817 学习 · 9566 问题
相似问题