qq_镜子里的我_04296911
2018-04-26 11:33
var mywin=window.open("http://www.imooc.com");
function clk(){
mywin.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="clk()" value="点击我,关闭网站" />
</body>
稍微改动了一下
<!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>
window.open()方法的作用就是新打开一个窗口,如果你想关闭当前窗口直接用 onClick="window.close",如果是想两个窗口同时关闭,需要在clk()函数中加一行window.close;
JavaScript入门篇
739817 学习 · 9566 问题
相似问题