Re: not to use cookie in tabbed menu ?

Matt Raible <lists-T7vlz3gD7BdF/EzeuO4KJwC/[email protected]>
Newsgroups gmane.comp.java.struts-menu.user
Message-ID <[email protected]>
Here's a tabs.js that doesn't use cookies.  The tabs.js that ships with 
struts-menu tries to match on URL and if it finds more than one 
matching URL, that's when it drops back to cookies.  So cookies are 
just a backup.  The problem with using URLs only is you might have a 
link that no menu items match, and then you won't get any tabs 
selected.

Matt

tabs.js
------
if (!document.getElementById) {
     document.getElementById = function() { return null; }
}

function initMenu() {
     activateMenu();
}

function activateMenu() {
     var menu = document.getElementById("menuList");
     var items = menu.getElementsByTagName("li");

     // match on URL
     for (var i=0; i < items.length; i++) {
         var url = items[i].firstChild.getAttribute("href");
         var current = document.location.toString();
         if (current.indexOf(url) != -1) {
             if (items[i].parentNode.className == "submenu") {
                 items[i].firstChild.className="selected";
                 items[i].parentNode.parentNode.className="selected";
             } else {
                 items[i].className+="selected";
             }
             break;
         }
     }
}

// Select the menu that matches the URL when the page loads
window.onload=initMenu;

On Jan 4, 2005, at 4:00 AM, lixin chu wrote:

> Hi,
> would like to try out the tabbed menu, but understant
> that it uses cookie. does it mean that a use will see
> the last tab selected when he accesses a page again ?
>
> if so, how to disable the cookie and let struct action
> set the active tab ?
>
> thanks
> li xin
>
>
> 		
> __________________________________
> Do you Yahoo!?
> Jazz up your holiday email with celebrity designs. Learn more.
> http://celebrity.mail.yahoo.com
>
>
> -------------------------------------------------------
> The SF.Net email is sponsored by: Beat the post-holiday blues
> Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
> It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
> _______________________________________________
> struts-menu-user mailing list
> struts-menu-user-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
> https://lists.sourceforge.net/lists/listinfo/struts-menu-user



-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.