Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Window close() method

Window close() method

Window Object Reference 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 example below can close a new browser window:

function openWin(){

    myWindow=window.open("","","width=200,height=100");

    myWindow.document.write("

This is 'my window'

");

}

function closeWin(){

    myWindow.close();

}

Try it »


Window Object Reference Window Object