AW! Google Gadgets

Switch Content Script
from Dynamic Drive

Abstract

Simple website utility from Dynamic Drive, a source of a small range of useful and relible scripts. It hides and reveals content as the reader wants it, adding to the interactivity of your page. Switch Content script — © Dynamic Drive (www.dynamicdrive.com). This notice must stay intact for legal use. Last updated April 2nd, 2005. Visit http://www.dynamicdrive.com/ for full source code.
Page Tags: Dynamic Drive utility code, Google Gadgets
Site Tags: Israelites Adelphiasophism Christmas Marduk Deuteronomic history Persecution inquisition the cross svg art Belief Solomon crucifixion contra Celsum sun god dhtml art Jesus Essene
Loading
There is nothing which can better deserve our patronage than the promotion of science and literature. Knowledge is in every country the surest basis of public happiness.
George Washington (1790)

Expand-Contract Script

© Dynamic Drive 2004-5. Contents Updated: Sunday, 21 December 2008

Dynamic Drive has some excellently reliable free DHTML and javascript scripts, some of which we use. This is one of them, a javascript for hiding content until the reader wants to see it, and is therefore interactive—just as websites should be.

▼ Contract All | ▲ Expand All

Data

This script works with virtually any content on your page to make them expandable. The two steps required are:

1. Create the header that will expand a content when clicked on. Here's an example:

<h2 onClick="expandcontent('sc1')"
style="cursor:hand; cursor:pointer"> A Heading</h2>

The part in red is the only required portion—everything else you can customize, from the header's style to even the tag used (ie: <img> instead of <h2>).

2. Specify the content that will be associated with the above and become expandable:

<div id="sc1" class="switchcontent"> JavaScript is a scripting language originally developed by Netscape..... </div>

Only the portion in red is necessary. The ID attribute used above (ie: sc1) can be arbitrary, but must match the “sc1” specified within the header of step 1) so that the header knows which content it should expand. Now, feel free to swap the <DIV> tag used to surround your content with a different container tag, such as <span>, <p> etc.

That's It

When the page first loads, by default the participating content is contracted. The user has to click to expand it. To make any content visible from the start, use the CSS “display” property:

<div id="sc1" class="switchcontent" style="display:block"> " </div>

And that's it. The script is adaptable, and easily integrated into any apge.

Specifying the “expand” and “contract” symbols

You can use different symbols in your headers, depending on the contracted or expanded state of the DIV content. In the script of Step 1 are two variables, one for each symbol. HTML is supported, so you can specify a simple “+” and “-” symbol, use character codes, as we have here, ▲ and ▼, or use images: "<img src='a.gif'>" and "<img src='b.gif'>"

Having created your symbols, insert the code:

<span class="showstate"></span>

inside each of your header HTML (code of Step 2, as shown). The script does the rest!



Last uploaded: 20 December, 2010.

Short Responses and Suggestions

* Required.  No spam




New. No comments posted here yet. Be the first one!

Other Websites or Blogs

Before you go, think about this…

Careful tests of the efficacy of prayer have always failed even when Christians did the testing. Thirty top US astrologers could not identify someone's personality profile from their birth date. Belief in the supernatural and in religion is usually conditioned. It runs in families and peer groups. Such people want a simple explanation for everything, even if it is inadequate. Rather than admit they do not know, they will accept a supernatural explanation and they prefer easy childish explanations to proper ones that are too hard for their brains. Science hurts their brains, but God loves them. That is the distinction!

Support Us!
Buy a Book

Support independent publishers and writers snubbed by big retailers.
Ask your public library to order these books.
Available through all good bookshops

Get them cheaper
Direct Order Form
Get them cheaper


© All rights reserved

Who Lies Sleeping?

Who Lies Sleeping?
The Dinosaur Heritage and the Extinction of Man
ISBN 0-9521913-0-X £7.99

The Mystery of Barabbas

The Mystery of Barabbas.
Exploring the Origins of a Pagan Religion
ISBN 0-9521913-1-8 £9.99

The Hidden Jesus

The Hidden Jesus.
The Secret Testament Revealed
ISBN 0-9521913-2-6 £12.99

These pages are for use!

Creative Commons License
This work by Dr M D Magee is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.
Permissions beyond the scope of this license may be available at http://www.askwhy.co.uk/.

This material may be freely used except to make a profit by it! Articles on this website are published and © Mike Magee and AskWhy! Publications except where otherwise attributed. Copyright can be transferred only in writing: Library of Congress: Copyright Basics.

Conditions

Permission to copy for personal use is granted. Teachers and small group facilitators may also make copies for their students and group members, providing that attribution is properly given. When quoting, suggested attribution format:

Author, AskWhy! Publications Website, “Page Title”, Updated: day, month, year, www .askwhy .co .uk / subdomains / page .php

Adding the date accessed also will help future searches when the website no longer exists and has to be accessed from archives… for example…

Dr M D Magee, AskWhy! Publications Website, “Sun Gods as Atoning Saviours” Updated: Monday, May 07, 2001, www.askwhy .co .uk / christianity / 0310sungod .php (accessed 5 August, 2007)

Electronic websites please link to us at http://www.askwhy.co.uk or to major contents pages, if preferred, but we might remove or rename individual pages. Pages may be redisplayed on the web as long as the original source is clear. For commercial permissions apply to AskWhy! Publications.

All rights reserved.

AskWhy! Blogger

↑ Grab this Headline Animator

Add Feed to Google

Website Summary