Results 1 to 4 of 4

Thread: Switch Content Script II (icon based)

  1. #1
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Switch Content Script II (icon based)

    1) Script Title: Switch Content Script II (icon based)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...chcontent2.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.

  2. #2
    Join Date
    Aug 2004
    Posts
    9,887
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Well, to make the persistence site wide, change the line below inside switchcontent.js with the addition in red:

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

  3. The Following User Says Thank You to ddadmin For This Useful Post:

    stevember (03-11-2008)

  4. #3
    Join Date
    Mar 2008
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

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

  5. #4
    Join Date
    Aug 2004
    Posts
    9,887
    Thanks
    3
    Thanked 962 Times in 951 Posts
    Blog Entries
    15

    Default

    Quote Originally Posted by stevember View Post
    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):

    Code:
    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:

    Code:
    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()

  6. The Following User Says Thank You to ddadmin For This Useful Post:

    stevember (03-12-2008)

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
  •