window.close無法關(guān)閉新頁面。代碼如下
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>無標(biāo)題文檔</title>
<script type="text/javascript">
function Wopen(){
window.open('http://www.baidu.com','_blank','height=400,width=600,top=100dp,left=0dp');
window.close();
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="點(diǎn)擊我,打開新窗口!" / >
</body>
</html>
2016-12-19
你這樣關(guān)閉的是你原來的那個(gè)頁面, 你應(yīng)該關(guān)閉的是你打開的那個(gè)頁面的對象
var mychar =window.open('http://www.baidu.com','_blank','height=400,width=600,top=100dp,left=0dp');
mychar.close();
2016-12-28
<!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://idcbgp.cn");
? ? ?setInterval(function(){
? ? ? ? ?mywin.close();
? ? ? ? ?},3000);
? ? ? ??
? </script>
</head>
<body>
</body>
</html>