Collapsible Menus + Cookie settings

Electronic Punk

willalwaysbewithyou
Staff member
Political Access
Joined
2 Dec 2001
Messages
18,694
I have been looking for a script that will allow me to collapse and expand menus easily and save that data across sessions using cookies.

Thought I had one...

(rename to .html and .js)
 

Attachments

  • collapser_html.txt
    488 bytes · Views: 126
  • collapser_js.txt
    3.7 KB · Views: 111
Was very pleased and was looking at a way of integrating it into our headline block having told Neobond and Redmak that I loved it and was going to have to steal the idea. (gave em more to compensate)

Put it in my makeshift test theme:
http://www.osnn.net/index.php?&themeid=3

(also had some other work done it on, been cleaning up the menus and changing a few things before I push it out to the other themes - clearing things up for some reason)

You can see the script in action at the top, but sadly for some reason it is
a) collapsed by default (bad)
b) doesn't save across sessions so remains collapsed.

This is the most suitable script I could find and I have been looking for a while.

Any cookie pro's why is this not working?

Collapse bit isn't final by the way, I just wanted to get it working.
 
It's not remaining open/closed because no cookie is being set. ;)

And it's default to closed because of this
Code:
if (document.getElementById){
document.write('<style type="text/css">')
document.write('.switchcontent{[b]display:none;[/b]}')
document.write('</style>')
}
which, to me at least, seems a nasty way of doing it anyway.
 
Well I am of course open to new scripts :D
Also why is it not setting a cookie? Because one exists?

Works offline ? :s
 
Hmm, cookie doesn't seem to be working now, must have cut too much out! :eek:
 
Can't wait :)

Was thinking it was because I didn't give the div an id, cos the source script works fine, but it erm, wasn't.
 

Attachments

  • index_source.txt
    4.6 KB · Views: 143
worst that can happen if it doesn't work in an old version of firefox is that they will just see everything.
 
LordOfLA said:
Except it dont work in firefox 1.5.0.1 (dont ask - i keep asking for .3 to be rolled out across active directory...)
Works fine in 1.5.0.3, and I doubt there were any major changes in the javascript engine between the two versions.

You sure you have JS enabled?
 
cookified :p

Works for me in WebKit, Gecko and Opera (Can't test IE ;P).

The cookie could be a bit more refined, rather than setting it to a date in May 2100, but for simplicities sake, that's how I've done it in the example :D
 
That seems to be a rather large script for such simple functionality.

Have changed it to only one link is showing now. Niff. :)
 
Oooh spangley.
Any idea why its not working on the frontpage?

Trying to put them in a .js if I can which is called in the header tag, could be the problem.
 
Yup, due to the way it interacts, the JS needs to be in the body, below the div/item we're collapsing. You can still call it via a .js, but it just needs to be below. :)
 
put it right at the bottom, must have overlooked something else.
 
Just had a quick look,

<div class="content" ... >

should be

<div id="content" ... >

:)
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back