JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

Site Navigation

6. All Browsers

clr gif

We can combine the javascript and PHP versions to give a version that works on all browsers but only displays the button on browsers without javascript. The code to do this is as follows:

<form name="ex3" action="xfer.php" method="POST">
<div align="center">
<select name="xfer" size="1"
onmouseup= "location = '' + this.optionscontinued from previous line[this.selectedIndex ].value;">
<option value="bltime1.htm">Introduction</option>
<option value="bltime2.htm">Get the Script</option>
<option value="bltime3.htm">Configure the Script</option>
<option value="bltime4.htm">Daylight Saving</option>
</select>
<noscript><input type="submit" value="Go!" />
</noscript>

</div></form>

Now all we need to do in order to place as many page links within this single drop down box is to add extra option statements for each page that we want to link to. If the open list becomes too long to be able to display properly on the screen then a scroll bar will be automatically added so that the visitor can scroll through your list of links to find the one that they want.

Of course if we want to allow a really large number of pages to be selected then the list can become too long. In that case we may want to list the most popular pages but allow our visitors to enter the less popular page names themselves. To do this we need a Combo Box in place of the drop down list.

1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9

Note that the script and the descriptions of the functions that it contains are rewritten from the "Ask Felgall" website with the permission of the copyright owner.

Explore JavaScript

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

JavaScript

  1. Home
  2. Computing & Technology
  3. JavaScript

©2009 About.com, a part of The New York Times Company.

All rights reserved.