Got Ads?
2/09/2005
  Testing the Show / Hide JavaScript for Blogger
For long posts, I want to be able to have people see the first paragraph or so of a post, and then have a link that calls a JavaScript script to reveal the next paragraph. This is a simple CSS / DOM trick, and the blogger help pages describe one way to do it. However, the blogger help pages show you how to use it when you want it to apply to all of your posts. If you just have a few longs posts, you need to adapt it. What I did was to take the same JavaScript:
function expandcollapse (postid) {
   whichpost = document.getElementById(postid); 
   if (whichpost.className=="postshown") { 
      whichpost.className="posthidden"; 
   } else { whichpost.className="postshown";} 
} 
</script>
And the CSS that were provide in the help page:
.posthidden {display:none}
.postshown {display:inline}
And simply create my own span, with a made up id in the post. Do a view source on this post to see how it works.
[+/-] Expand / Collapse this section
 




<< Home

Subscribe to GotAds?



Links



Recent Posts

Testing the Show / Hide JavaScript for Blogger


Archives

February 2005 /  March 2005 /  April 2005 /  May 2005 /  June 2005 /  July 2005 /  August 2005 /  September 2005 /  October 2005 /  November 2005 /  December 2005 /  January 2006 /  February 2006 /  March 2006 /  April 2006 /  May 2006 /  June 2006 /  July 2006 /  August 2006 /  September 2006 /  October 2006 /  November 2006 /  December 2006 /  January 2007 /  February 2007 /  March 2007 /  April 2007 /  May 2007 /  June 2007 /  July 2007 /  August 2007 /  September 2007 /  October 2007 /  November 2007 /  December 2007 /  January 2008 /  February 2008 /  March 2008 /  April 2008 /  May 2008 /  June 2008 /  July 2008 /  August 2008 /  September 2008 /  November 2008 /  December 2008 /  January 2009 /  March 2009 /