H I O X INDIA
Javascript Tutorial
 HOME  ||  Scripts  ||  Purchase  ||  Tutorials  ||  Images  ||  Tools  ||  Directories 
  :-)  Send Page   :-)   Feedback   :-)   Register   :-)   Links   :-)   Support   :-)   Bookmarks :-)  
 Forums   Hosting   Internet Stats   Easy Calculation   FUN Games 

Java-Script Tutorial
Introduction
Variables
Operators
Statements
Loops
Functions
Objects
Arrays
Browser Objects
Form DOM
Ask Your Doubts
Feedback





Window Close Function


Topic

How to close the new browser window using javascript?
or
Code to close a page or window on button click



Explanation

Object: Window

Method or Function: close()

Closing current window?:
Closing the current page or window is very simple. Just calling close() or this.close() will close the window.

Closing a newly opened window?:
Closing the window that was created or opened by open method. For this we should use the reference that we obtain when the new browser window is created. The procedure is as follows

a) On opening a window, store the return object (window) in a variable
e.g: var xcv = open('url','name');

b) call close function or method on that window object
e.g: xcv.close();

Example: This example will close the window when a button click is done.
Code:
<script language=javascript>
function closer()
{
this.close();
}
</script>

<form name=xcv>
<input type=button onClick="closer()" value="click to close">
</form>





        Javascript (JS) is one of the most used languages in the world. Some times spelled as Java Script. Hope you enjoy this tutorial. Do send your feedback or suggestions on this javascript or java script tutorial. This is a copyright content.

others

privacy policy     license     sitemap
© 2004-2005 HIOX INDIA - hioxindia.com

Other Links