为什么总是同时打开两个网页而点按钮却只能关闭一个,哪位大神能帮我看看?代码如下:
var mywin=window.open("http://www.imooc.com");
function clk(){
mywin.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="clk()" value="点击我,关闭网站" />
</body>
var mywin=window.open("http://www.imooc.com");
function clk(){
mywin.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="clk()" value="点击我,关闭网站" />
</body>
2018-04-26
稍微改动了一下
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
<script type="text/javascript">
var mywin=window.open("http://www.imooc.com","_blank","width=600,height=400,top=100,left=0");
function clk(x){
x.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="clk(mywin)" value="点击我,关闭网站" />
</body>
</html>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>close()</title>
<script type="text/javascript">
function clk(){
var mywin=window.open("http://www.imooc.com");
mywin.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="clk()" value="点击我,关闭网站" />
</body>
</html>
举报