<script language="javascript" type="text/javascript">function closeWindow() {window.open('','_parent','');window.close();}</script> 
<a href="javascript:closeWindow();">Close Window</a>

解决方案 »

  1.   

    clare2003(忘情火):
    非常感谢, window.open('','_parent',''); 这句什么作用呢?
      

  2.   

    fool the browser into thinking that it was opened with a script
    This opens a new page, (non-existent), into a target frame/window, (_parent which of course is the window in which the script is executed, so replacing itself), and defines parameters such as window size etc, (in this case none are defined as none are needed). Now that the browser thinks a script opened a page we can quickly close it in the standard way…