background
|
|
bonsai
The Element
A small area for Bonsai related material.
More icon

Computer
|
|
Up Image
Navigation
Search this Site
Enter your search terms

Site Breadcrumb - You are here
|
Thau's JavaScript Tutorial
Lesson 3

by Thau!

Page 4 — Examples of Opening Windows with JavaScript

Try clicking on these three links and see what happens. Don't close any of the windows until you've clicked on all three links.

Here's a window named javascript_1.
Here's a window named javascript_2.
Here's another HTML page going into javascript_1.

Let's take a look at how this is done. Here's the first line:

<a href="#" onClick="window.open('javascript_window_1.html','javascript_1'); return false;">Here's a window named javascript_1</a>.

When you click on this link, a new window called javascript_1 gets opened and the HTML page javascript_window_1.html gets put into the window. Because the features parameter is optional, you can just leave it out. This will give you the default window you would have gotten if you'd used a targeted href, as in the previous page.

Notice that I put the call to open the window in an onClick. You don't have to put window.open() calls inside an onClick, it was just convenient to do so in this example. You'll see examples of window.open() inside <script> tags soon.

The second link is almost exactly like the first link. It just opens a window with a different name and loads in a different HTML page:

<a href="#" onClick="window.open('javascript_window_2.html','javascript_2'); return false;"> Here's a window named javascript_2</a>.

The third link sticks a new HTML page into the first window. This works because the third link opens a window with the same name as the first window: javascript_1.

<a href="#" onClick="window.open('javascript_window_3.html','javascript_1'); return false;">Here's another HTML page going into javascript_1</a>.

Now the fun begins. We can play with the features parameter to make our windows look very different.

OK already, let's play with windows features!

next page»