X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

Window close() Method

Window Object Reference Window Object

Example

Use open() to open a new window, and close() to close the new window:

function openWin() {
    myWindow = window.open("", "myWindow", "width=200, height=100");    // Opens a new window
}

function closeWin() {
    myWindow.close();                                                  // Closes the new window
}

Try it yourself »


Definition and Usage

The close() method closes the current window.

Tip: This method is often used together with the open() method.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The close() method is supported in all major browsers.


Syntax

window.close()

Parameters

None.

Return Value

No return value.


More Examples

Example

Open "www.w3schools.com" in a new window, and use close() to close the window:

function openWin() {
    myWindow = window.open("http://www.w3schools.com", "_blank", "width=200, height=100");
}

function closeWin() {
    myWindow.close();
}

Try it yourself »


Window Object Reference Window Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook