Window close()Method

Window 对象参考手册Window Object

Definition and Usage

The close() method is used to close a browser window.

Syntax

window.close()


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the close() method


Example

Example

The following example can close the new browser window:

function openWin(){
    myWindow=window.open("","","width=200,height=100");
myWindow.document.write("<p>This is 'my window'</p>");
}
function closeWin(){
    myWindow.close();
}

Try it Yourself »


Window 对象参考手册Window Object Other Extensions