indiWiz.com
SiteSearch:
Jump:

Site Map | WizTools.org | jCraze Blog
Web Developer's Den!
Home : WDD : JavaScript
This Article...
Print Version
Add Comment
View Comments
JavaScript
The Bare Facts
Rollover Script
Script Windows
Status Message
Time Sensibility of JavaScript
JavaScript and Frames
Expandable Menus
Cursor Effects!
Regular Expressions Reference
JavaScript Screen Size
JavaScript HTMLize (Using Regular Expressions)
Java Script Dynamic Time Update
Sections

Commniquè
Sign Guestbook!
Read Guestbook!
MailMe!

Subhash's Guide: JavaScript Windows

Window is the top object in the DOM hierarchy. And as any other object in the hierarchy, this too can be created manipulated and destroyed.

Opening a New Window

Syntax:
window.open(url,name,features,replace);

The method open() should be called on the window object to open a window. A simple script showing how to open a window with the url 'http://www.indiwiz.com/' is given below:

<script language="JavaScript">
<!--
function popUp(){
window.open("http://www.indiwiz.com/");
}
//-->
</script>

This function may be called through any link(<a href="javascript:popUp();">XXX</a>), form element or automatically on document loading or on closing an existing window.

The url parameter of the method open() is mandatory. So what if you wanted to open a blank window? Then you have to pass a null string as url. The same example would be:
window.open('');

The second parameter of the method open() is name. This can be used with target attribute.

Another important parameter which the method open() accepts is the 'features'. Using various arguments within this parameter you can customize the look, size, display area etc. of the window. The various arguments within this parameter are listed below:

FeaturesValue
statusyes/no
locationyes/no
toolbaryes/no
menubaryes/no
scrollbarsyes/no
fullscreenyes/no
resizableyes/no
directoriesyes/no
height#(px.)
width#(px.)
top, screenY#(px.)
left, screenX#(px.)

One thing you have to note is that all these arguments form part of a single parameter. Thus the whole argument should be placed within quotes.

The last in the list of parameters which the open() method accepts is the optional 'replace'. Unlike other parameters(which are strings), this one is a boolean argument. 'true' adds the displayed site to the browser history and vice versa.

Open a Window with the following:

  • URL - http://www.indiwiz.com/
  • Without status bar, location bar & tool bar.
  • The height of the window is 500 pixels.
  • The width 640 pixels.
The code is:

<script language="JavaScript">
<!--
function popUp(){
window.open("http://www.indiwiz.com/","subhash","status=no,location=no,toolbar=no,width=640,height=500",true);
}
//-->
</script>

Execute the script!

Closing a Window

Syntax:
window.close();

The close() method doesn't take any arguments.


User Comments

Add Comment

[Quick Stats: Number of main threads: 1, Number of sub-threads: 1]


Sign Guestbook | Who is Subhash?
The contents of this site are copyright© 2000-2008, indiWiz.com. All Rights Reserved.