It's Not Just
Help. . .
So How Does It Work?
Topics & Templates
Project File (.hhp)
Contents File (.hhc)
Merging Modular Files
Distribution & Installation
HTML Help Resources on the Web
Open Secondary Window Recipe
This recipe allows you to open a new browser window when the user clicks
on the paragraph or other HTML element containing the call to the function.
(Note that the purpose for this recipe is misprinted in the book; it
repeats the "purpose" paragraph from the recipe for an alert
message using input from a prompt.
The function shown in the book on p. 215 should not have quotation
marks around "url" and "windowName"
in the line beginning window.open (url, windowName... However,
you must have single quotes around 'url' and 'windowName'
in the call within the element. The correct code is shown below and
in the downloadable text file.
Click here to open a new window.
window.open(url, windowName, "height=x, width=y, menubar=yes, resizable=yes,
scrollbars=yes, status=yes, toolbar=yes")
is a variable passed from the calling element to the function.
This variable identifies the URL of the page displayed in the window;
is another variable passed from the calling element to the function.
This variable supplies the name used to refer to the window in scripts;
describe the overall size of the secondary window in terms of the
number of pixels in the height and width (respectively);
menubar, scrollbars, toolbars
are navigation elements displayed if the value is yes (the
default) or not displayed if the value is no;
determines whether the user can change the window’s size (default=yes;
may also =no);
is the message area at the bottom of the window; displayed if yes
(the default), hidden if no.
Call within the element
here to open a new window.</P>
As it stands, this recipe allows you to specify the URL and window
name for each link. If you will always use the same window name, you
could remove the variable windowName from the first line of
the function, so that you pass only the URL as a variable: function
openWindow(url). Then, within the body of the function, supply
an actual name instead of using the windowName variable.
You can also open a new window directly from an event handler, without
using a function at all. For example, to use a button to open a new
window and show an animated demonstration of a process, you could include
the following code:
<FORM><input type="button" value="Show
Me How" onClick="window.open('url', 'windowName', 'height=x, width=y,
menubar=yes, resizable=yes, scrollbars=yes, status=yes, toolbar=yes')"></FORM>
The components of the element handler have the same meaning as in the
original function, except that url and windowName
should be the actual URL and window name, rather than variable names.