拉滴嘎嘎
2016-11-22 10:21
function winopen()
{var open=confirm("是否在新窗口中打开网站?");
if(open==true)
{var url=prompt("是否输入新网址?","http://www.imooc.com");
if(url!=null)
{window.open(opp,"_blank",width=400px,height=500px,menubar=no,toolbar=no);
}
else
{alert("结束");}
}
else
{alert("结束");}
}
<!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 a=confirm("你是否要打开慕课网");
if(a==true){
var b=prompt("你确定要打开慕课网?","http://www.imooc.com");
if(b!=null){
window.open("http://www.imooc.com","_blank","width=400,height=500,menubar=no,toolbar=no")
}
}
}
// 通过输入对话框,确定打开的网址,默认为 http://www.imooc.com/
//打开的窗口要求,宽400像素,高500像素,无菜单栏、无工具栏。
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
function名winopen与onclick的openWindow不同;
window.open(opp,"_blank",width=400px,height=500px,menubar=no,toolbar=no)中opp是新变量,opp应为url;
width=400px,height=500px,menubar=no,toolbar=no应加引号
window.open(url,"_black","width=400px,height=500px,menubar=no,toolbar=no");
切记加引号
function winopen(){
var open=confirm("是否在新窗口中打开网站?");
if(open==true){
var url=prompt("是否输入新网址?","http://www.imooc.com");
if(url!=null){
window.open(opp,"_blank",width=400px,height=500px,menubar=no,toolbar=no);
}else{
alert("结束");
}
}else{
alert("结束")
};
}这是你的代码,我改了一下,发现else有问题
确定在input标签中泄漏<input type="button" value="新窗口打开网站" onclick="openWindow()" />
里的onclick
JavaScript入门篇
741590 学习 · 9869 问题
相似问题