Results 1 to 2 of 2

Thread: Animated Collapsible DIV - setting persistance for site wide

  1. #1
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Animated Collapsible DIV - setting persistance for site wide

    1) Script Title: Animated Collapsible DIV

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

    3) Describe problem:
    Hi, the collapsible div script is a wonderful thing, but after looking at the javascript it appears the cookie sets persistance for each page not site wide.

    Code:
    var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "")
    Wondering if anyone knows how to set the persistance for collapse-expand on 1 div across the site?

    Thanks in advance!

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    That's right, the current persistence feature is page specific, meaning if you have two collapsing DIVs with the same ID (ie: id="mydiv") on two different pages, the two DIVs will be persisted independently of each other.

    If you wish the persistence feature to be site wide, firstly, you need to be aware that the ID you assign to your collapsing DIV now becomes a universal identifier of that exact DIV across all pages on your site. In other words, you cannot have two DIVs on two different pages that are not the same DIV use the same ID.

    With that in mind, to make the persistence universal, try the following (untested, but should work):

    Code:
    animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload")
    and changing it to:

    Code:
    animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(thisobj.divId, thisobj.isExpanded)}, "unload")
    Then the line:

    Code:
    document.cookie = name+"="+value
    and change that to:

    Code:
    document.cookie = name+"="+value+"; path=/"

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
  •