PDA

View Full Version : Changing Switch Content Headers



portkey
09-04-2007, 02:15 PM
1) Script Title: Switch Content I

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

3) Describe problem:

I was just wondering if there was a way to change the styling on the switch content script. I'm using CSS to add some style to the clickable headers, and by doing so I have added a :hover background image to them. My question is, is it possible to keep the background image on the header when it's DIV is expanded? I know in the script you can change the color, so I was wondering if there was a line of code I could add to the file that would give it a background image as well.

Thanks!

ddadmin
09-04-2007, 11:57 PM
Certainly. I've modified the original switchcontent.js file with the ability to specify a CSS background for either/both the Closed or Open state of the header. Download the attached .js file and replace the original with it. With that done, the old method setColor now accepts 2 more parameters, to be optionally used to specify the CSS background when the header is open and closed, respectively. So you can now do all of the following:


myexample.setColor('green', 'red')
myexample.setColor('green', 'red', 'url(open.gif)') //Open headers carry a background
myexample.setColor('green', 'red', '', 'url(closed.gif)') //Closed headers carry a background
myexample.setColor('green', 'red', '', 'url(open.gif)', 'url(closed.gif)') //Both open/closed headers carry a background

The valid values for the 3rd and 4th parameter is any valid CSS background declaration, such as 'transparent url(test.gif) no-repeat'.

portkey
09-05-2007, 10:35 AM
thank you so much! it works perfectly :D