<!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 st=confirm("你确定要打开窗口吗?");
if(st==true);
{
var sp=prompt("默认网站是","http://www.baidu.com");
if(sp==null);
{window.open(url,"_blank",'width=400px,height=500px,menubar=no,toolbar=no');}
}
else
{
alert("The end");
}
else
{
alert("The end");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>1、if(sp==null)修改为if(sp!=null);
2、url没有赋值,可以更改为‘sp’。解释:这里的url没有任何意义,改为‘sp’后,就是运行sp输入的结果,输入什么网址就会打开什么网址
<!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("你确定要打开窗口吗?");
if(open==true);
{
var sp=prompt("默认网站是","http://www.baidu.com");
if(sp!=null);
{window.open(sp,"_blank",‘width=400px,height=500px,menubar=no,toolbar=no’);}
}
else
{
alert("The end");
}
else
{
alert("The end");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openwindow()" />
</body>
</html>
URL 呢? OPEN谁就写谁
if(sp==null);这行删掉
你默认的网址是"http://www.baidu.com",不进行任何编辑返回值为"http://www.baidu.com",不为空,所以后边的if没有执行
prompt();后面直接window.open();就行
你下面的两个else重复,删掉一个
url 没赋值,从哪里跑出来的