PDA

View Full Version : Switch Content Script - Standalone script needed!...



beach_borosix
11-11-2010, 06:37 PM
1) Script Title: Switch Content Script

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

Hello!... Firstly, thanks for the scripts!...

Sorry about this but... Could some kind person please update this script so I could store it somewhere else on my site please!...



<script type="text/javascript">
// MAIN FUNCTION: new switchcontent("class name", "[optional_element_type_to_scan_for]") REQUIRED
// Call Instance.init() at the very end. REQUIRED

var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
bobexample.setStatus('<img src="http://img242.imageshack.us/img242/5553/opencq8.png" /> ', '<img src="http://img167.imageshack.us/img167/7718/closedy2.png" /> ')
bobexample.setColor('darkred', 'black')
bobexample.setPersist(true)
bobexample.collapsePrevious(true) //Only one content open at any given time
bobexample.init()
</script>


I would like to take it off the page so any help would be very appreciated!...

Beverleyh
11-11-2010, 07:11 PM
Do you mean that you want to pull out the code (less the opening/closing script tags) into a seperate .js file and then reference the code with a link?

Like <script type="text/javascript" src="switchcontent_load.js" ></script>

beach_borosix
11-11-2010, 07:36 PM
Do you mean that you want to pull out the code (less the opening/closing script tags) into a seperate .js file and then reference the code with a link?

Like <script type="text/javascript" src="switchcontent_load.js" ></script>

Hello!... That's exactly it!... But if you take out the opening and closing tags and put it into a script, it will not work on it's own!... It needs to be updated slightly... I have been trying but I am a simpleton!... Please help!...

Beverleyh
11-11-2010, 07:55 PM
I'm not sure what you mean. I tested it using the method I briefly described and it works fine - no updates to the script are necessary.

Please post a link to your web page so we can see whats going wrong.

Beverleyh
11-11-2010, 07:59 PM
My test page;

<html>
<head>

<script type="text/javascript" src="switchcontent.js" >
/***********************************************
* Switch Content script- (c) Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
</script>

<style type="text/css">
/*Style sheet used for demo. Remove if desired*/
.handcursor{
cursor:hand;
cursor:pointer;
}
</style>

</head>
<body>

<h2>Demo 1</h2>

<div><a href="javascript:bobexample.sweepToggle('contract')">Contract All</a> | <a href="javascript:bobexample.sweepToggle('expand')">Expand All</a></div>

<h3 id="bobcontent1-title" class="handcursor">What is JavaScript?</h3>
<div id="bobcontent1" class="switchgroup1">
JavaScript is a scripting language originally developed by Netscape to add interactivity
and power to web documents. It is purely client side, and runs completely on the client's browser and computer.
</div>

<h3 id="bobcontent2-title" class="handcursor">Difference betwen Java & JavaScript?</h3>
<div id="bobcontent2" class="switchgroup1">
Java is completely different from JavaScript.
The former is a compiled language while the later is a scripting language.
</div>

<h3 id="bobcontent3-title" class="handcursor">What is DHTML?</h3>
<div id="bobcontent3" class="switchgroup1">
DHTML is the embodiment of a combination of technologies- JavaScript, CSS, and HTML.
Through them a new level of interactivity is possible for the end user experience.
</div>

<script type="text/javascript" src="switchcontent_load.js"></script>

</body>
</html>

switchcontent_load.js;

var bobexample=new switchcontent("switchgroup1", "div") //Limit scanning of switch contents to just "div" elements
bobexample.setStatus('<img src="http://img242.imageshack.us/img242/5553/opencq8.png" /> ', '<img src="http://img167.imageshack.us/img167/7718/closedy2.png" /> ')
bobexample.setColor('darkred', 'black')
bobexample.setPersist(true)
bobexample.collapsePrevious(true) //Only one content open at any given time
bobexample.init()

beach_borosix
11-11-2010, 08:28 PM
http://www.borosix.co.uk/test/test_a.html

beach_borosix
11-11-2010, 08:30 PM
I tried to use the url's you gave me and the text disappeared!...

beach_borosix
11-11-2010, 08:37 PM
Belay all of that... I didn't put the link at the bottom... I did it and guess what... Thanks and d'oh!...