活在梦里3980862
2016-10-16 00:25
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function foo(){
var bli=confirm('确定打开新世界的大门吗?');
if (bli==ture)
{var url=prompt("在下面网址输入key就可以啦",'http://www.bilibili.com/');
if (url!=null)
{window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');}
else {alert('prompt关闭');}
else {alert('confirm关闭');}
}}
</script>
</head>
<body>
<input type="button" value="打开新世界的大门" onclick="foo()" />
</body>
</html>
第一:if语句里面应该是true而不是ture;
第二:prompt语句后面的分号要是英文输入下的,你用的是中文状态下的了;
第三:第一个else后面应该跟一个分号表示第一个if语句结束,你把它放到最后去了
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html; charset=gbk"/>
<script type="text/javascript">
function foo(){
var bli=confirm('确定打开新世界的大门吗?');
if (bli==true)//这里ture改为true
{var url=prompt("在下面网址输入key就可以啦",'http://www.bilibili.com/');/*这里改为英文状态下的*/
if (url!=null)
{window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');}
else {alert('prompt关闭');}}//这里加上一个括号
else {alert('confirm关闭');}
}//这里去掉一个括号
</script>
</head>
<body>
<input type="button" value="打开新世界的大门" onclick="foo()" />
</body>
</html>
上面说得都对,嘻嘻
content="text/html" charset="gbk"/
if(bil != null)
<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta http-equiv="Content-Type" content="text/html" charset="gbk"/>
<script type="text/javascript">
function foo()
{
var bil =confirm("是否打开大门");
if(bil == true){
var url = prompt("要去玩吗?","http://www.bilibili.com");}
if(bil != null)
{window.open(url,'_blank','width:400,height:500,menubar=no,toolbar=no');}
else
{alert("关闭");}
}
</script>
</head>
<body>
<input type="button" value="打开新世界的大门" onclick=" foo()" /> </body>
</html>
window.open(url,'_blank','width=400,height=500,menubar=no,toolbar=no');
多个)号
JavaScript入门篇
741593 学习 · 9869 问题
相似问题