spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

JavaScript Tip of the Week for September 23, 1996: Source Code: Saving Space on Your Site

Simple Select Menu
A JavaScript Billboard
Modifiable Select Menu II



Put this code in the head of the page for the select menu:

/* This code is Copyright (c) 1996 Nick Heinle and Athenia Associates, 
 * all rights reserved. In order to receive the right to license this 
 * code for use on your site the original code must be copied from the
 * Web site webreference.com/javascript/. License is granted to user to 
 * reuse this code on their own Web site if and only if this entire copyright
 * notice is included. Code written by Nick Heinle of webreference.com.
 */

function MakeArray()
        {
        this.length = MakeArray.arguments.length
        for (var i = 0; i < this.length; i++)
        this[i+1] = MakeArray.arguments[i]
        }

var siteopt = new MakeArray("Select a Page",
                            "Browse Past Tips",
                            "This Week",
                            "E-Mail",
                            "JavaScript Powered Tour",
                            "Tippettes");

var url = new MakeArray("",
                        "../tip_week_past.html",
                        "../this_week/index.html",
                        "../e-mail.html",
                        "../960617/index.html",
                        "../tippettes.html");

function jumpPage(form)
{
        i = form.SelectMenu.selectedIndex;
        if (i == 0) return;
        window.location.href = url[i+1];
}


Put this where you want the selet menu to be displayed:

    document.writeln('<FORM><SELECT NAME="SelectMenu" onChange="jumpPage(this.form)">');
    tot = siteopt.length;
        for (var i = 1; i <= tot; i++)
        document.write("<OPTION>" +siteopt[i]);
    document.writeln('</SELECT>');
    if (navigator.userAgent.indexOf("Mozilla/2") != -1)
    document.writeln('<INPUT TYPE = BUTTON VALUE = "Jump!">');
    document.writeln('</FORM>');



Put this code in the head of the page for the billboard:

/* This code is Copyright (c) 1996 Nick Heinle and Athenia Associates, 
 * all rights reserved. In order to receive the right to license this 
 * code for use on your site the original code must be copied from the
 * Web site webreference.com/javascript/. License is granted to user to 
 * reuse this code on their own Web site if and only if this entire copyright
 * notice is included. Code written by Nick Heinle of webreference.com.
 */

var boardNum = 0;
var transNum = 0;
var boardSpeed = 2000;
var transSpeed = 150;

billboard = new Array;
billboard[0] = new Image(31, 250);
billboard[0].src = "../this_week.gif";
billboard[1] = new Image(31, 250);
billboard[1].src = "../archive.gif";
billboard[2] = new Image(31, 250);
billboard[2].src = "../bguide.gif";

url = new Array;
url[0] = "../this_week/index.html";
url[1] = "../tip_week_past.html";
url[2] = "../guide/index.html";

trans = new Array;
trans[0] = new Image(31, 250);
trans[0].src = "trans0.gif";
trans[1] = new Image(31, 250);
trans[1].src = "trans1.gif";
trans[2] = new Image(31, 250);
trans[2].src = "trans2.gif";
trans[3] = new Image(31, 250);
trans[3].src = "trans3.gif";
trans[4] = new Image(31, 250);
trans[4].src = "trans4.gif";
trans[5] = new Image(31, 250);
trans[5].src = "trans5.gif";
trans[6] = new Image(31, 250);
trans[6].src = "trans6.gif";

function changeBoard() {
        if (transNum > trans.length - 1) {
        boardNum++;
        transNum = 0; 
                if (boardNum > billboard.length - 1) boardNum = 0;
        displayBoard();
        return;
        }
        else {
        document.billboardimg.src = trans[transNum].src;
        setTimeout("changeBoard()", transSpeed);
        }
transNum++;
}

function displayBoard() {
document.billboardimg.src = billboard[boardNum].src;
return;
}

function boardControl() {
trueboardSpeed = boardSpeed + (trans.length * transSpeed);
changeBoard();
setTimeout("boardControl()", trueboardSpeed);
}

function jumpBillboard() {
window.location.href = url[boardNum];
}


Put onLoad = "boardControl()" in the BODY tag and put this where you want the billboard displayed:
<A HREF = "javascript:jumpBillboard()"
 onMouseover = "window.status = url[boardNum];return true;"
 onMouseout = "window.status = '';return true;">
<IMG BORDER = 0 HEIGHT = 31 WIDTH = 250 SRC = "../this_week.gif" NAME = "billboardimg"></A>

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint