Opening page in new window (custom size, etc)

<html>
<head>
<script language=javascript>
<!-- Hide from older browsers
      function winBob( ) {window.open('winbob.html','bob','width=450,height=180') }
// End hiding -->
</script>
</head>
 
<body>
<a href="5newwin.html" onClick="winBob( )">1</A> Bob Scott Campground
</body>
</html>

This is another script which uses the "onClick" event handler. In this case, "onClick" is connected to a link rather than a button. "onClick" triggers a user-defined function which has been stored in the <head> portion of the html document.

JavaScript Functions   A function is a set of Javascript commands or statements that the user can create and store for future use. Functions are given a name - e.g. "winBob( )" - and are stored in the <head> portion of an html document. The function is then executed whenever it is "called" from the body of the document. In the above script excerpt, when the "onClick" event handler is triggered it calls "winBob( )" which results in a new window being opened.
   This is the general syntax used to create a function:
    function myFunction( ) { javascript statement;
                                     javascript statement;
                                     etc......; }

In the New Window script example, the code could have just as easily been written as a single line to be placed within the <a href> tag:
  onclick="window.open( 'winbob.html','bob','width=450,height=180' )"
However, often a function is reused several times within an html document. (The next demo illustrates a function that is used for more than one purpose).

More About Opening New Windows   The generic JavaScript code for opening a new window is:
  window.open( 'yourPage.html','thePageName','property=??,property=??,...' )
Some common window properties include width, height, scrollbars, resizable, location and toolbar. Desired properties are strung together separated only by commas (no spaces!). For example, a set of properties might look like this:
  'width=300px,height=100px,scrollbars=yes,resizable=yes,toolbar=no'