慕粉3628429
2016-11-28 10:40
<!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 mysrt=confirm("是否打开网页");
if (mysrt==true)
{
var my=prompt("请输入网址","http://www.imooc.com/");
if(my !=null){
window.open(my,'http://www.imooc.com','_blank','width=400px,height=500px,menubar=no,toolbar=no')
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 mysrt = confirm("是否打开网页");
if (mysrt == true) {
var my = prompt("请输入网址", "http://www.imooc.com/");
if (my != null) {
window.open(my, 'http://www.imooc.com', '_blank', 'width=400px,height=500px,menubar=no,toolbar=no')
}
else{
alert("再见");
}
}
else {
alert("再见!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openwindow()" />
</body>
</html>//以上代码已经修改完毕,测试成功
代码我看了一会,原来是ifelse{}符号不匹配,下次遇到这种问题,试试用chrome的检查工具查看问题,刚刚,一下就找到问题所在了
<!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 mysrt = confirm("是否打开网页");
if (mysrt==true)
{
var my=prompt("请输入网址:","http://www.imooc.com/");
if(my != null){
window.open('http://www.imooc.com','_blank','width=400px,height=500px,menubar=no,toolbar=no');
}else{
alert("再见!");
}
}else{
alert("再见!");
}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
测试通过了!一些标点的问题
if ..else.函数那里写的有问题,第二个if和else之间少了一个大括号
if(my !=null){
window.open(my,'http://www.imooc.com','_blank','width=400px,height=500px,menubar=no,toolbar=no')}
else{alert("再见");
}JavaScript入门篇
741708 学习 · 9869 问题
相似问题