JavaScript : Open, Close, and Modify Browser Windows
Contents ]
Dr Benton

Integrating a JavaScript Function in an HTML Link

This code can be incorporated in a JavaScript function or in an HTML link:

<A HREF="javascript:void(0)" onClick="Our JavaScript code">Link anchor text</A>

Here is an anchor tag example:

<A HREF="javascript:void(0)" onClick="window.open('stracy.jpg','Spencer','width=190,height=210');" >Another window</A>

The window displayed will be adapted to the content size:

Another window

Don't forget the borders. In our example, the image size is 165 x 185 pixels. We have added 25 pixels to the window width and height to provide room for the white space that surrounds the image when it is displayed.