Questions and Answers on Chrys`s Approach to Active Client Pages
(Page 1 of 5 )
In this eleventh part of a twelve-part series on active client pages (ACP), I give you more factors that gave rise to the Window Phase of Chrys’s Approach. We continue with the questions and answers more or less from where we left off last time.
How do I close a window?
You close a window using the window close() method. Let us look at it.
HTML DOM close() Method
Definition and Usage
The close() method is used to close the current window.
Syntax
window.close()
Example
The following example closes the new window:
<html>
<head>
<script type="text/javascript">
function closeWin()
{
myWindow.close()
}
</script>
</head>
<body><script type="text/javascript">
myWindow=window.open('','','width=200,height=100')
myWindow.document.write("This is 'myWindow'")
</script>
<input type="button" value="Close 'myWindow'" onclick="closeWin()" />
</body>
</html>
From my experience, even though the specification says that the close() method is used for the current window, if you are at a window, and you have a reference to some other window, you can use the reference to close the window as follows:
windowRef.close();
Next: Can you open a window, which will open another window, which will open another window and so on? >>
More JavaScript Articles
More By Chrysanthus Forcha