Results 1 to 6 of 6

Thread: collapsing menu when returning to index.htm page

  1. #1
    Join Date
    Nov 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default collapsing menu when returning to index.htm page

    1) Script Title: Switch Menu 1

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...switchmenu.htm

    3) Describe problem: Is there a way to have the pesitance work as normal but for the menus to collapse when loading a particular page ie the index page?... in essence to lose the persitance on jst that page??

    Cheers

  2. #2
    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

    Yes, on that page, set it to no:

    From the Demo Page:
    Code:
    <script type="text/javascript">
    
    /***********************************************
    * Switch Menu script- by Martial B of http://getElementById.com/
    * Modified by Dynamic Drive for format & NS4/IE4 compatibility
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    var persistmenu="no" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
    var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only
    If you still want changes made on that page to be reflected on other pages running the script, change this line from the script on that page as well:

    Code:
    if (persistmenu=="yes" && document.getElementById)
    to:

    Code:
    if (document.getElementById)
    - John
    ________________________

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

  3. #3
    Join Date
    Nov 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi John

    Thanks for this and the follow up on the other thread. one question though..

    The site uses the external menu.js file to control the actions of the menu. If I make the changes you recomend then would this not mess up the persistance all the pages?...

    Thanks

    Steve

  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

    There is no such external file with this script though, of course, one could be employed and would probably be a good idea if the same menu is used on numerous pages.

    There are at least two ways to go in such a situation. You could remove the call to the external file from the one page and put a separate copy of the script, with the desired changes, on that page.

    Or, what I would recommend, is to set things up so that different values could be used on the one page but still employing the external file. There are quite a number of ways to do that, here's one. On the external script, all you need are these changes (red):

    Code:
    var persistmenu=typeof isindex=='undefined'? "yes" : "no"; //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
    and:

    Code:
    if ((persistmenu=="yes"||typeof isindex!='undefined') && document.getElementById)
    window.onunload=savemenustate
    Then on your index page have this before the call to the external script:

    Code:
    <script type="text/javascript">
    var isindex=1;
    </script>
    - John
    ________________________

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

  5. #5
    Join Date
    Nov 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok thanks,

    I'll give it a try..... and let you know

    Cheers

  6. #6
    Join Date
    Nov 2006
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    ACE!!

    Works like a dream thanks John!

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
  •