Back to Index

JavaScript Examples
Changing Background Colours
Mortgage Calculator
Carbon Dating Calculator
Let The Banners Fly!
Online Quiz
Days to the Millenium
A Simple MouseOver (Rollover) Script

PopUp Windows

Creating and Controlling PopUp windows with JavaScript

In each of the examples above, a new window is opened when the link is clicked on.
Inside each tag for a link a JavaScript event handler is added:

<A HREF="javascript:onClick=(popLink('onblur.htm'))"> Example One: </a>

a more common link is:
<a href="#" onClick="(popLink('onblur.htm'))"> Example One:
But it has a drawback in that the page will scroll to the top at each click

<A HREF="javascript:onClick=(popLink('onblur.htm'))">
Whichever one you choose to use activates the JavaScript in the HEAD of this document:

<script language="javascript">
function popLink(Link){
popup = window.open(Link, "newwin","height=200,width=300,scrollbars=no")
}
</script>

It's in this script that you designate which document appears in the new window as well as set the size of the window and determine whether there are scroll bars etc. Any number of these links can exist on a page, each triggering a different window to open.

Many thanks to Ian Cowell for help with the JavaScript in this page.