Free Scripts |
|
Creating a
Navigation Menu in JavaScript: Step 2 by Christopher
S.L.Heng,
As written, whenever the user selects an item, he will
immediately be transported to that page, even if he has not clicked
on "Go!" button. If you don't like this behaviour, simply remove the
"onchange" attribute for the "select" tag. That is, your select tag
should be modified to look like:
<select name="newurl">
The user will then have to click the button to go to the new
URL.
If, on the other hand, you like the default behaviour
of automatically transporting the user to the new page when he
changes the selection, you can remove the submit button since it
will never be used. That is, remove the line that reads:
<input type=submit value="Go!"
onclick="menu_goto(this.form)">
If you prefer not to
tamper with the above code, you can leave it as it is and the menu
will still function well.
There are, however, certain
changes to the code that are unavoidable: in particular, you need to
adapt the linked-to pages for your site. As the sample code stands,
it only gives the user the option to go to your index.html and
feedback.html pages as well as to http://www.thefreecountry.com/. To
adapt it for your site, put the actual page name in the value
attribute of each option tag, and put the title of the page
that you want displayed after the tag. So, if for example you wanted
to put a link to your Company Information page, which has a URL of
companyinfo.html relative to the current page, you would add a tag
like the following:
<option
value="companyinfo.html">Company Information
If you like,
you can always use the complete URL of each page, so that you need
not worry about broken links when you cut and paste the menu to
pages located in subdirectories.
Next Step: Changing Your Pages >>
Copyright 2000 by Christopher S L Heng. All rights reserved.
Visit http://www.thefreecountry.com/ for more free
articles, resources and tools for webmasters and software
programmers.
|
|