Close Window with window.close in Javascript
To close a window with window.close in Javascript:
<a href="#" onclick="window.close()">Close Window</a>
or
<a href="#" onclick="self.close()">Close Window</a>
You could also call window.close() as the end of a
function.
Example:
function chrisWindow() {
// do some other Javascript here.... example:
alert("This window is about to close.");
window.close();
}
To avoid the Internet Explorer warning message, open the window with Javascript's
window.open method.
Example:
<a href="#" onclick="window.open('test2.shtml');return false">Open Window</a>
Then in your test2.shtml place your link containing Javascript's window.close()
<a href="#" onclick="window.close()">Close Window</a>
Free Copy and Paste Javascript Code:
<a href="#" onclick="window.open('test2.shtml');return false">Open Window</a>
<a href="#" onclick="window.close()">Close Window</a>
Resources:
Opening a REMOTE WINDOW in Javascript