PDA

View Full Version : Style Sheet Switcher Question



froglicka
01-09-2010, 01:53 AM
1) Style Sheet Switcher (v1.1)

2) http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm

3) Describe problem:

I have 5 buttons:

One makes the font bigger
One makes the font smaller
One makes the font return to default
One makes the font green
One makes the font return to default

-

If I make the font big and then press green, it makes the font green but at the default size...?

Please could someone help me combat this?

Kindest Regards,

Rob

ddadmin
01-10-2010, 01:48 AM
Inside the CSS for making the font green, does it contain any rules that may cause the text to be resized to its default size? A link to the problem page might help.

froglicka
01-10-2010, 03:52 AM
I deleted the code I am afraid, I decided not to go down this route. Thanks for enquiring though :)!

Nile
01-10-2010, 03:55 AM
It seems your topic is solved... Please set the status to resolved.. To do this:
Go to your first post ->
Edit your first post ->
Click "Go Advanced" ->
Then in the drop down next to the title, select "RESOLVED"

djr33
01-10-2010, 05:14 AM
For anyone else who has a similar question, here's how (following the post by ddadmin):

1. Follow the basic ideas in the first post.
2. Include ONLY properties in each css file that relate to the specific change required. This way switching to "green" will change the settings for color, but the old settings for size should remain. Then changing the size will update only the size, and the new green color will remain.
I think this should work smoothly, but you should check in several browsers to be sure.

jscheuer1
01-10-2010, 05:03 PM
Not really. The way the style switcher works is that there is one default stylesheet that's always active and one or more alternates that all start out disabled. Each time the function runs it disables all but 0 or 1 of the alternates. So when switching to green you will have whatever font-size is in the default unless overridden in green, in which case you will have that. You will never have the font-size defined in any of the other alternates.

The script would need a rewrite (probably fairly major) to allow for various alternates to be enabled at once. If so, what you say djr33 could work.

However, if the font-size for the entire page is simply based upon the inherited percent font-size of the body element (a good practice anyway in most cases), a cookie could be setup just for that and it could be handled via a direct command along the lines of:


document.body.style.fontSize = '90%';

That way color and font-size changes could then both be saved and be independent of each other.

Nile
01-10-2010, 05:08 PM
The script would need a rewrite (probably fairly major) to allow for various alternates to be enabled at once.

Tons of scripts on DD need a major rewrite - half of them can be done with maybe 20 lines of code, including this one.