<!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 url=prompt("输入网址","http://www.imooc.com/")};
// 新窗口打开时弹出确认框,是否打开
if(uil!=null)
{window.open(url,'_blank,width=400px,height=500px,menubar=no,toolbar=no')
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("再见哦")}
else
{alert("再见")}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
<!DOCTYPR HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>window.close</title>
<script type="text/javascript">
// 新窗口打开时弹出确认框,是否打开
/* function openWindow(){
var mytc = confirm("是否打开");
if(mytc==true){
window.open('http://www.imooc.com');
}else if(mytc==false){
alert('不想打开新窗口');
}
}*/
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
/* function openWindow(){
var mytc = prompt("输入想要打开的网站:");
if(mytc!=null){
window.open('http://'+mytc);
}else{
alert("没有想打开的网址");
}
}*/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
/* function openWindow(){
window.open('http:www.imooc.com','_blank',' width=400,height=500,toolbar=no,menubar=no,status=no,scrollbars=yes');
}*/
function openWindow(){
var mytc = confirm("是否打开");
if(mytc==true){
var mytc = prompt("输入想要打开的网站:");
if(mytc!=null){
window.open('http://'+mytc,'_blank',' width=400,height=500,toolbar=no,menubar=no,status=no,scrollbars=yes');
}else{
alert("没有想打开的网址");
}
}else if(mytc==false){
alert('不想打开新窗口');
}
}</script>
</head>
<body>
<input name="button" type="button" onClick="openWindow()" value="新窗口打开网站!" />
</body>
</html>
我的是这样的,你可以参考一下
<!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 url=prompt("输入网址","http://www.imooc.com/");//右中括号去掉
// 新窗口打开时弹出确认框,是否打开
if(url!=null)
{window.open(url,'_blank','width=400px,height=500px,menubar=no,toolbar=no')}//参数单独加上引号
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("再见哦")}
}//右中括号位置应该在这里
else
{alert("再见")}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
<!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 url=prompt("输入网址","http://www.imooc.com/")
if(url!=null)
{window.open(url,'_blank','width=400px,height=500px,menubar=no,toolbar=no')
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("再见哦")}
}
// 新窗口打开时弹出确认框,是否打开
else
{alert("再见")}
}
</script>
</head>
<body>
<script type="text/javascript">
function openWindow()
{var open=confirm("确定打开新网页吗");
if(open==true);//;去掉
{var url=prompt("输入网址","http://www.imooc.com/")};//右中括号去掉
// 新窗口打开时弹出确认框,是否打开
if(uil!=null)
{window.open(url,'_blank,width=400px,height=500px,menubar=no,toolbar=no')}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
else
{alert("再见哦")}
} //右中括号位置应该在这里
else
{alert("再见")}
}
</script>
你的错误类型:
你多出使用了中文括号,应该改成英文括号;
if(uil!=null)你写成了uil,应承接上面的变量是 url;
你的if-else逻辑嵌套错误;
if(条件语句){代码块},条件语句)后面不要加分号,语句的结束需要加分号,函数体}后不加分号。
修改之后代码如下:
我来纠正下你的问题:第一:f(uil !=null)打错了,第二:注意下() 括号注意下中英文切换。
不行,更换了之后还是不出来消息对话框
if(uil !=null)
{
window.open(url , '_blank' , 'width=400px,height=500px,menubar=no,toolbar=no');
}
应该是if(url != null),你手误了。