Archive for JavaScript

JavaScript – close window

Monday, April 6th, 2009

JavaScript allow us to close window with inbuilt functions.

This is easier for user to close window with just pressing link or button. User doesn't have to go through browser file close option. This will work with pop up window of browser.

Javascript have function to close window

window.close()

self.close()

This function closes window which is opened.

The example of closing window is given where you can test how it works.

<html>
<head>
<title>Javascript close window</title>
</head>

<body>
<input type="button" name="btn" value="Close" onclick="window.close()" />
</body>
</html>

Demo