Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Javascript JavaScript open() method

Related Tutorials


 
 

Share on Google+Share on Google+

JavaScript open() method

Advertisement
This open() method is very useful for the programmers. Here is a case when this might be very useful.

JavaScript open() method

     

This open() method is very useful for the programmers. Here is a case when this might be very useful. Suppose you are filling some information on the form and at that time you are required to perform some task on another page then either you have to click on browser to create new window or you may loose all information filled in that form. So here the JavaScript's open() method may be very helpful.

JavaScript's open() method is used to open a new browser window. Syntax for open() method is as follows :

Syntax:

 window.open(URL, name, specs, replace);

Different arguments and their meanings are as described below :

Arguments  Description
URL It specifies the URL of the opening page
name It specifies the target attribute. It may have following values:
  • _blank : URL loaded into new window
  • _parent : URL loaded into parent window
  • _self : URL replaces current window
  • _top : URL replaces any framesets that may be loaded
  • name : name of the window
specs Comma separated list of items which defines the different attributes for the new opening windows.
replace It is a boolean value and specifies that whether to open new window by replacing the URL history link or to create new entry in history list.

All above four arguments or parameters are optional.

Here we have created an example into which when the user clicks on the button open() method would be called. Full HTML code is as follows :

<html>
 <head>
   <title> Open method Example </title>
     <script  type="text/javascript">
	function windowOpen(){
	  window.open("http://www.roseindia.net");
	}
     </script>
 </head>
 <body>
  <div style="background: #335556; width:'100%';"
    align="center">
   <font color="#ffddff" size="12pt">
	<b>open method example</b>
   </font>
  </div>
 <center>
 <input type="button" value="Open a new window" 
      onClick="windowOpen();">
 </body>
</html>

Output :

Click on the button "Open a new window"

Download Source Code

     

Advertisements

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: February 7, 2009

Related Tutorials

Discuss: JavaScript open() method  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com