之前问了好几个人,都说不能实现通过js打开一个新的界面并关闭。为了验证这个想法我就试了试,没想到竟然真的可以实现 下面贴出代码
<html> <head> <script language="javascript"> var newWindow; newWindow=window.open("http://www.baidu.com"); //alert(123); //alert(typeof(newWindow)); setTimeout('newWindow.close()',1000); </script> </head> <body > </body> </html>
测试发现window.open()函数的返回值是一个window 对象
如果要实现父界面关闭 直接调用函数 window.close();