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

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

JavaScript Tip of the Weekfor 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 


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>