<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>close()</title> <script type="text/javascript"> function rec(){ var mywin=window.open("http://www.imooc.com"); setTimeout("mywin.close()",1000); } </script> </head> <body> <input name="button" type="button" onClick="rec()" 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 rec(){
var mywin=window.open("http://www.imooc.com");
setTimeout('1000');
mywin.close()
}
</script>
</head>
<body>
<input name="button" type="button" onClick="rec()" value = "点击查看网页" />
</body>
</html>
这样就自动关闭了。