/    Sign up×
Community /Pin to ProfileBookmark

Expand/Collapse text without .js in <head> HowTo

Hey,

Anyone have a simple script that will allow me to expand/collapse text, without having to reference a .js in the <head>? I need a script that can function out of the <body>

Thanks.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KravvitzNov 07.2005 — Just put the script in <body>.

It's best practice to keep them in <head>, but you don't have to.
Copy linkTweet thisAlerts:
@Lotus9authorNov 07.2005 — What script do you recommend?
Copy linkTweet thisAlerts:
@KravvitzNov 07.2005 — *shrugs* I just write a custom one when I need one.

[url=http://www.google.com/search?q=JavaScript+show+hide+script]Maybe one of these would suit your needs.[/url]
Copy linkTweet thisAlerts:
@Lotus9authorNov 09.2005 — Hey,

I used this code:

&lt;script type="text/Javascript"&gt;

function expandcollapse (postid) {

whichpost = document.getElementById(postid);

if (whichpost.className=="postshown") {
whichpost.className="posthidden";
}
else {
whichpost.className="postshown";
}
}
&lt;/script&gt;


It works great, but in FF, whenever someone expands a section, and then returns it to normal, it leaves a giant white gap below where the bottom of my page is suppose to be. It doesn't do this in IE...how do I fix that? Any ideas?

Thanks.
Copy linkTweet thisAlerts:
@KravvitzNov 09.2005 — Please provide a link to the page in question.
Copy linkTweet thisAlerts:
@Lotus9authorNov 10.2005 — Krav,

Check yer PM's. ?
×

Success!

Help @Lotus9 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...