PDA

View Full Version : Switch Content Script II (icon based)



stevember
03-11-2008, 04:27 PM
1) Script Title: Switch Content Script II (icon based)

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/switchcontent2.htm

3) Describe problem: Works great on my menu/navbar but I use it as an include() for lots pages, can the cookie be site wide?

Also, can it be default open even if persistence on.

ddadmin
03-11-2008, 07:36 PM
Well, to make the persistence site wide, change the line below inside switchcontent.js with the addition in red:


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


Also, can it be default open even if persistence on.

You'll have to elaborate what you're trying to do.

stevember
03-11-2008, 08:53 PM
switchcontent.setCookie=function(name, value, days){
if (typeof days!="undefined"){ //if set persistent cookie
var expireDate = new Date()
var expstring=expireDate.setDate(expireDate.getDate()+days)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()
}
else //else if this is a session only cookie
document.cookie = name+"="+value+"; path=/"
}

Thats perfect for session but what need change for if number days are defined?

To then other, default is closed unless specified. But overwritten by persistent.
I would like open by default.

ddadmin
03-12-2008, 06:41 AM
Thats perfect for session but what need change for if number days are defined?


You can do this by also changing this line within the script with the code in red (leave the previous change above intact):


document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/"


To then other, default is closed unless specified. But overwritten by persistent. I would like open by default.

The persistence feature will always override any default content open/close setting. However, you can have a specific content be open by default (before any repeat visit to that page causes the persistence to kick in that is) by calling defaultExpanded() with the indices of the content that should be expanded by default, for example:


var faq=new switchicon("icongroup1", "div") //Limit scanning of switch contents to just "div" elements
faq.setHeader('<img src="minus.gif" />', '<img src="plus.gif" />') //set icon HTML
faq.collapsePrevious(true) //Allow only 1 content open at any time
faq.setPersist(false) //No persistence enabled
faq.defaultExpanded(0,1) //1st and 2nd content expanded
faq.init()