<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript">
function Wopen() {
var open=confirm("确定打开?");
if (open==true) {
var url=prompt("打开新窗口?","http://www.imooc.com");
if (url!=null) {
window.open(url,"http://www.imooc.com","_blank","width=400px,height=500px,menubai=no,toolbar=no");
}
else {
alert("goodbye");
}
} else {
alert("goodbye");
}
</script>
</head>
<body>
<input name="button" type="button" onclick="Wopen" value="打开新窗口"/>
</body>
</html>如题,自己也找不到错误。
代码中的Wopen open url 是唯一指定的名字还是可以替换,或者是随便怎么命名都可以。
之前我做打开窗口练习的时候,函数名命名为Wopen才有效果,随便起个名字怎么试都不行。
百度也搜不到相关内容。
求大神讲解一下里边规则或者贴个博客地址。
明显少了一个大括号
window.open(url,"http://www.imooc.com","_blank","width=400px,height=500px,menubai=no,toolbar=no");
改为
window.open(url,"_blank","width=400px,height=500px,menubai=no,toolbar=no");
试试?
onclick="Wopen" 应该是onclick="Wopen()"