We have just created our first script. We will now move onto something a little more challenging. It is assumed that you have read and at least partially understand the document "Perceptons of HTML and JavaScript" or have some programming experience. In the next example we will make use of an HTML link tag and an event handler which will call a function to open a new window.



<title>An example script</title>

<script language=javascript>

/* Use these symbols to add comments */


function myWindow() {

goWindow = window.open('hello.gif', 'myWin', 'height=310,width=310, scrollbars=no,location=no, toolbar=no')




<a href="javascript:myWindow()">Click Me</a>


This script use the function myWindow (notice the capital W" to create a window whose variable name is goWindow. The window's name is myWin. This is important if you want to access or reference the window later. The other parameters: height, width, toolbar, scrollbars, location are optional albeit useful in some cases.

Important: single quotes must be used. All items between single quote pairs must be on the same line (The goWindow stuff).

The link javascript:myWindow() calls the function of the same name and activates the new window.

See it in action...
Click Me