[thelist] JavaScript Help Please!
danielEthan
daniel at ionize.net
Fri Mar 28 17:02:32 CST 2003
Hi evolters,
I'm having a problem with a Javascript that's driving me crazy. The for
loop is only firing once, when I want it to keep going. Onload, I'm
calling rememberNavigation, which is loops through the cookie, looking
for those with "nav" in the name. When that's found, I want it to use
my already existing function toggleNavigation. As it is now, this works
for the first cookie with nav, but then stops.
TIA!
Here's the script:
// TOGGLE DISPLAY OF NAVIGATION
function toggleNavigation(object, state) {
var id = styleObject(object);
var img = "tgl" + object.substr(3);
var expandImg = newImage("./_library/images/navigation/expand.gif");
var collapseImg =
newImage("./_library/images/navigation/collapse.gif");
var objImg = document.images[img];
if ((id.display == "") || (state == "collapsed")) {
id.display = "none";
window.status = "[+] expand";
objImg.src = expandImg.src;
setCookie(object, "collapsed");
} else if (id.display != "") {
id.display = "";
window.status = "[-] collapse";
objImg.src = collapseImg.src;
deleteCookie(object);
}
//return true; <-- tried this, but to no avail
}
// USE COOKIES TO REMEMBER NAVIGATION
function rememberNavigation() {
var dc = document.cookie;
alert(dc);
var dc_array = dc.split(";");
for (i=0; i < dc_array.length; i++) {
if (dc_array[i].indexOf("nav") != -1) {
var nav_array = dc_array[i].split("=");
toggleNavigation(nav_array[0], nav_array[1]);
// continue; <-- likewise, no help
}
}
}
More information about the thelist
mailing list