PDA

View Full Version : Content Contracted on page load



Vaz
08-05-2006, 02:03 PM
1) Script Title: Switch Content Script II
2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm
3) Describe problem:
Id like the page to load with all the items contracted rather than expanded. How can I do this?

ddadmin
08-05-2006, 06:16 PM
Sure, simply edit function do_onload() inside the script with the below changes:


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.

Vaz
08-05-2006, 09:25 PM
Thanks alot :)

sharmin
08-06-2006, 08:58 PM
Sure, simply edit function do_onload() inside the script with the below changes:


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

blm126
08-06-2006, 09:01 PM
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).

ddadmin
08-08-2006, 01:50 AM
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.

Relentless
08-11-2006, 10:24 PM
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?

Relentless
08-11-2006, 10:33 PM
Found it:

http://www.dynamicdrive.com/forums/showthread.php?t=11755&highlight=Switch+Content+Script