qq_天兲开心_0
2016-01-02 00:12
<!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 np=prompt("请输入网址","http://www.imooc.com/");
if(np==null)
{
window.open(np,"width=500,height=40,menubar=no,toolbar=no");
}
else{alert("ko");}
}
else{alert("ko");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html
没太看懂你np==null这个if else想实现什么意思?
修改了一个:
<!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 np = prompt("请输入网址","http://www.imooc.com/");
window.open(np,"_blank","width=500,height=40,menubar=no,toolbar=no");
}
else{alert("ko");}
}
</script>
</head>
<body>
<input type="button" value="新窗口打开网站" onclick="openWindow()" />
</body>
</html>
JavaScript入门篇
739816 学习 · 9566 问题
相似问题