Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Easy Java Script Windows

Opening a browser window with JavaScript is extremely easy. If you don't believe me, type this text into your web page.


When you open your web page, a popup window named about:blank will appear.

In the code above we have used the fact that the browser defaults to Java Script. Proper coding would have specified the script language and assigned the window to a variable so that we could use that variable to control the window after we create it. The example below shows the proper code to create a window and load a web page named mypage.htm into the window.

<script language="JavaScript">
var myPopUp = window.open("mypage.htm","pop_window");

Of course, you don't have to load a local web page into the window, you can put any URL in the first argument of the window.open function. Note the second argument of the window.open function, "pop_window". This gives the window a name that you can use to load a different page into the window, as shown below.

<a href="mypage2.htm" target="pop_window">Link Text</a>

You can add a third argument, called the "features list", to the window.open function. Below is a list of the features that you can specify.

leftlocation of the left border of the window in pixels from the left side of the screen
toplocation of the top border of the window in pixels from the top of the screen
widthwidth of the window in pixels
heightheight of the window in pixels
menubarspecifies the menu bar
toolbarspecifies the tool bar
locationspecifies the address bar
scrollbarsspecifies scrollbars
statusspecifies the status bar
resizespecifies whether the window can be resized by the user

Assigning a feature the value 1 provides the feature. Assigning a feature the value 0 prevents the feature. The example below creates a window with a menu bar and address bar, but no tool bar. Note that the feature specifications are separated by commas, and you can put them in any order.

<script language="JavaScript">
var myPopUp = window.open("mypage.htm", "pop_window",
  "menubar=1, location=1, toolbar=0");

What happens if you omit the specification of a feature? That depends on the browser version used to view the page. In some browsers, features not specified appear by default. In some browsers features not specified are not provided by default. To get reliable results, you should always specify all the features.

If you like to reuse code, you can specify the features list in a string variable and then use that variable name as the features list argument in the window.open function. This will prevent you from having to memorize the features list.

<script language="JavaScript">
var features = "left=100, top=100, width=256,
  height=256,   menubar=1, toolbar=0, location=0,
  scrollbars=0, status=0";
var myPopUp = window.open("mypage.htm",

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268