PDA

View Full Version : Switch Content Script: absolute vs relative URL



cway
10-27-2010, 10:01 PM
1) Script Title: Switch Content Script

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

3) Describe problem: I'm using the script in Wordpress and suspect I need to use an absolute URL to the javascript file. I say this because when I use the script on a static page with a relative URL to the .js file, it works fine. Any ideas?

Thanks!
Cway

ddadmin
10-28-2010, 08:08 AM
On blogs where the URL of each page can be very complex and not always reflective of the true directory structure of your site, yes, it's prudent to just specify an absolute URL to the .js file, ie:


<script type="text/javascript" src="http://mysite.com/scripts/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>

cway
10-28-2010, 12:32 PM
That's what I thought, but it doesn't work in Wordpress:
http://dev.smilefortcollins.com/ask-the-dentist/

It works on a static page:
http://www.smilefortcollins.com/test.shtml

Any suggestions?
Thanks for the quick response!
Cway

ddadmin
10-28-2010, 08:20 PM
On your wordpress page, there is an error with the initialization code for the script:


<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</p>
<p>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>

As you can see, there's an inadvertent P tag inside it. :)

cway
10-28-2010, 08:34 PM
Fixed! Thanks for the quick response and for the script.