JavaScript Tutorial





Español Français 中文 Deutsch Portuguese Japanese nederlands
   
 
Java-Script Tutorial
Introduction Introduction
Variables Variables
Operators Operators
Statements Statements
Loops Loops
Functions Functions
Objects Objects
Arrays Arrays
Cookies JS Cookies
Browser Objects Browser Objects
Form DOM Form DOM
Style Objects DOM Style Objects
Forums Ask Your Doubts
Scraps More about Javascript
Feedback Feedback
 




Window Open Method


Tutorials Javascript

Topic

How to create or open a new browser window using javascript?
or
Can we handle the size, position, location of new browser window?



Explanation

Object: Window

Method or Function: open(url,name[,properties])

Opening a new window?:
Open method or function is used to create or open new browser window in javascript. We have to pass two arguments url path and a name for that window. The window will be blank if you pass empty string ("") for url.

Example: Opening a link/url on button click
Code:
<script language=javascript>
open("http://www.hscripts.com","test");
</script>

Result:


Opening a new window with specified size, height, location, menu, status, scroll bar, etc..:
The new browser window can be created with specified height, width, location and other properties. These properties have to be passed as the third argument separated by comma.

Syntax: open("url","name","height=200,width=200,location=true,...");

The following table shows all the possible option that can be used while opening a new browser window.
OptionValuesDescriptionExample
Height Integer used to set the height of the new window. Code:
open("","","height=150");

Result:
Width Integer used to set the width of the new window. Code:
open("", "", "height=150,width=150");

Result:
Location Boolean used to display / hide the location bar in the new window. location bar is the place in the browser where the url is displayed. Code:
open("", "", "height=250,width=250, location=yes");

Result:
Resizable Boolean if resizable is set to yes, window resizing can be done by users. By default the window resizing is disabled. Code:
open("", "", "height=250,width=250, resizable=yes");

Result:
Menubar Boolean used to display/hide the Menu bar in the new browser window. Code:
open("", "", "height=250,width=250, menubar=yes");

Result:
Scrollbars Boolean Scrollbars option is used to display/hide scroll bars in the new browser window. Code:
open("", "", "height=250,width=250, scrollbars=yes");

Result:
Status Boolean Status option is used to display / hide the status bar in new browser window. Code:
open("", "", "height=250,width=250, status=yes");

Result:
Toolbar Boolean Toolbar option is used to display / hide the tool bar in new browser window. Code:
open("", "", "height=250,width=250, toolbar=yes");

Result:





A Note
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.

Other Links

web hosting