Get best price on Prepaid Cheapest Smartphone | ||||||||||||
|
||||||||||||
|
JavaScript: Pull-down MenuThe pull-down menu is an excellent way to condense many links into a small area. This article first shows you how to create a basic pull-down menu. Next, I explain variations for not providing a "go"-type button, using the menu with frames, and using the menu with pop-up windows. Here's a working example of our menu: The JavaScript that goes within the HEAD section of the document is:
<SCRIPT LANGUAGE="JavaScript"><!--
function openURL() {
selInd = document.theForm.aaa.selectedIndex; // get value of the selected option goURL = document.theForm.aaa.options[selInd].value; // redirect browser to the grabbed value (here a URL) top.location.href = goURL; //--> </SCRIPT> How the Menu Works The HTML portion is nothing more than a form, with a pull-down menu and a button which calls the above function. The different options in the menu define the URL and the text displayed. The GO button uses the onClick method to call our function. The code looks like:
<form name="theForm">
<tt>
<select name="aaa" size="1"> <option selected value="/index.php">Blazonry home </option> <option value="#">-------------------- </option> <option value="/info/hosting.php">How to Pick a Web Host </option> <option value="/scripting/adtest.php">Test Google Ads </option> <option value="#">-------------------- </option> <option value="/name_generator/wuname.php">wu name </option> <option value="/name_generator/usname.php"> US Name </option> <option value="/name_generator/babyname.php">Baby Name </option> <option value="#">-------------------- </option> <option value="/css/index.php">CSS Tutorial </option> <option value="/scripting/linksdb/index.php">Web DB Tutorial </option> </select> <input type="button" value=" GO " onClick="openURL()"> </tt> </form> Variations To The Pull-Down MenuPull-down Menu Without a GO button (automatically redirect) The changes needed to not have a "go" button are:
Change the SELECT item to include the onChange method to look like:
<SELECT NAME="aaa" SIZE="1" onChange="openURL()">
Using the Pull-Down Menu In Frames top.main.document.location.href=goURL;
Using the Pull-Down Menu In Pop-Up Windows An example: you have a small pop-up window you use for navigation that has the pull-down menu in it. You want it to change the main window that opened this document. You would use: opener.document.location.href=goURL;
Related blazonry.com article: JavaScript Pop-Up Windows.
|
privacy policy || © 1997-2016. astonishinc.com All Rights Reserved. |