Results 1 to 8 of 8

Thread: Content Contracted on page load

  1. #1
    Join Date
    Aug 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Content Contracted on page load

    1) Script Title: Switch Content Script II
    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...chcontent2.htm
    3) Describe problem:
    Id like the page to load with all the items contracted rather than expanded. How can I do this?

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

    Default

    Sure, simply edit function do_onload() inside the script with the below changes:

    Code:
    function do_onload(){
    uniqueidn=window.location.pathname+"firsttimeload"
    var alltags=document.all? document.all : document.getElementsByTagName("*")
    ccollect=getElementbyClass(alltags, "switchcontent")
    statecollect=getElementbyClass(alltags, "showstate")
    if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
    revivecontent()
    else
    sweeptoggle('contract')
    if (ccollect.length>0 && statecollect.length>0)
    revivestatus()
    }
    The code in red is new.

  3. #3
    Join Date
    Aug 2006
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks alot

  4. #4
    Join Date
    Jul 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin
    Sure, simply edit function do_onload() inside the script with the below changes:

    Code:
    function do_onload(){
    uniqueidn=window.location.pathname+"firsttimeload"
    var alltags=document.all? document.all : document.getElementsByTagName("*")
    ccollect=getElementbyClass(alltags, "switchcontent")
    statecollect=getElementbyClass(alltags, "showstate")
    if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
    revivecontent()
    else
    sweeptoggle('contract')
    if (ccollect.length>0 && statecollect.length>0)
    revivestatus()
    }
    The code in red is new.

    statecollect=getElementbyClass(alltags, "showstate")
    if (enablepersist=="on" && get_cookie(window.location.pathname)!="" && ccollect.length>0)
    revivecontent()
    else
    sweeptoggle('contract')

    if (ccollect.length>0 && statecollect.length>0)
    revivestatus()
    }[/CODE]


    Will you please explain, so that we understand, how this piece of code makes the menu contracted? What the if and else part is testing? I tried to understand, but I cannot at all. Please explain.

    Thanks a lot for your time, I hope that you have time for this question..

  5. #5
    Join Date
    Sep 2005
    Posts
    882
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Default

    It is testing whether persistence is on and whether the user has already been on the page(but it only tests that if persistence is on).

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

    Default

    Well, the persistence feature supercedes the "contract all" feature, so when a visitor visits the page for the first time, the content are all contracted as they should be, but assuming persistence is enabled, on subsequent visits, the persistence feature takes over and recalls the last states of the contents.

  7. #7
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I still have a question.

    When you load a page all content is contracted but on load for a second you can see the content before its beeing contracted and it's kinda annoying.

    So is it possible to load page without showing contracted content even for a part of second?

  8. #8
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

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
  •