Results 1 to 5 of 5

Thread: Smart Folding Menu Tree Script Cookie

  1. #1
    Join Date
    Jun 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Smart Folding Menu Tree Script Cookie

    Is it possible to change the cookie for this menu system to remember what menu is open on the previous page, and have those menu items be open on the page you just navigated to? currently it remembers the state of the menu on the page you left, and then when you leave that page and go to a new one it will set a new cookie for that page. if you then go back to the original page the menu items are open how you left them.

    i want the menu to be global and remember the state of the menu from page to page. does that make sense?

    Here is the cookie code:
    Code:
    <script language="JavaScript1.2">
    <!--
    
    function get_cookie(Name) {
    //Get cookie routine by Shelley Powers 
      var search = Name + "="
      var returnvalue = "";
      if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search)
        // if cookie exists
        if (offset != -1) { 
          offset += search.length
          // set index of beginning of value
          end = document.cookie.indexOf(";", offset);
          // set index of end of cookie value
          if (end == -1) end = document.cookie.length;
          returnvalue=unescape(document.cookie.substring(offset, end))
          }
       }
      return returnvalue;
    }
    
    var foldercontentarray=new Array()
    var c=0
    
    if (ns6){
    for (i=0;i<document.getElementsByTagName("UL").length;i++){
    if (document.getElementsByTagName("UL")[i].id=="foldinglist"){
    foldercontentarray[c]=document.getElementsByTagName("UL")[i]
    c++
    }
    }
    }
    
    if (get_cookie(window.location.pathname) != ''){
      var openresults=get_cookie(window.location.pathname).split(" ")
      for (i=0 ; i < openresults.length ; i++){
        if (ns6){
        foldercontentarray[openresults[i]].style.display=''
        foldercontentarray[openresults[i]].previousSibling.previousSibling.style.listStyleImage="url(open.gif)"
        }
        else{
        foldinglist[openresults[i]].style.display=''
        document.all[foldinglist[openresults[i]].sourceIndex -1].style.listStyleImage="url(open.gif)"
        }
      }
    }
    
    if (ns6||ie4){
    var nodelength=ns6? c-1 : foldinglist.length-1
    var nodes=new Array(nodelength)
    var openones=''
    }
    
    function checkit(){
      for (i=0 ; i <= nodelength ; i++){
        if ((ns6&&foldercontentarray[i].style.display=='')||(ie4&&foldinglist[i].style.display==''))
           openones=openones + " " + i
      }
      document.cookie=window.location.pathname+"="+openones
    }
    
    if (ns6||ie4)
    window.onunload=checkit
    //-->
    </script>

  2. #2
    Join Date
    Jun 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    *bump*

  3. #3
    Join Date
    Jun 2005
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    second bump- i really need help on this one.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It can be done, make it more like the persistence feature of:

    http://www.dynamicdrive.com/dynamici...switchmenu.htm

    with the 'sitewide' option.

    If you need help coding, I'll get to it as soon as I can but, if you have some knowledge of javascript, you should be able to make the changes yourself.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    May 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation

    I made every effort I was capable of to accomplish what you did with the latter mentioned menu script, but was unable to achieve persistence across pages for this script.

    I would suggest that if you had the time, it would greatly increase the value of this script to have persistence across all pages as an option.

    Thank you for the consideration.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •