This is a discussion on "Resizing the Font through Buttons/Links?" within the Web Page Design section. This forum, and the thread "Resizing the Font through Buttons/Links? are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Resizing the Font through Buttons/Links?
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Resizing the Font through Buttons/Links?
I've been asked to make the fonts on our site change size when a button corresponding to that size is pressed. I've searched google and all I can find it tips on how to go into the view menu of IE and changing it that way...
Anyway, a good example of this would be this website... http://www.webcredible.co.uk/ From it's source, it's using php to change the styles involved but I can't get at that code. Anyway, I'm using ASP with CSS so if I can keep it within those techs, great; if not, I could dabble with something else. I'm fairly new to web work so any ideas on how i approach this would be great. Thanks. |
|
|
|
||||
|
Re: Resizing the Font through Buttons/Links?
I don't know ASP, but the PHP solution is quite easy (at least conceptually) and should be quite similar other than the syntax. (Really, this would be fun to figure out if you didn't have to do it for work, LOL. There must be 6 different ways to do it.)
You could use a form. I give you an example using a GET value supplied in a link and write a cookie for you while I'm at it Put your font sizes in separate CSS files. Let's have four options, integers 1-4, corresponding to four font-stylesheets: small, normal, large, extra_larrge. Then high up in your header (might as well put it above the DOCTYPE declaration) do a handler and cookie to set a fontsize variable $fs, using a previous cookie only if there is no new GET value (so the user can change the cookie):
|
|
|||
|
Re: Resizing the Font through Buttons/Links?
That's great mason, thanks for the tips so far.
I'm not to hot on PHP so I opted for Javascript. This is what I've come up with so far ...
Also, accessibility-wise, what are the implications of using a scripting solution like javascript, does anyone know? Thanks again. |
|
||||
|
Re: Resizing the Font through Buttons/Links?
The best approach (but also, the most consuming) is to code a PHP (or any server side language) script that allows for stylesheet switching.
Then, add Javascript on top of this to provide some added behaviour to those that can support it. The most important thing you can do, is hard-code the main stylesheet, then allow for changing of others. Believe it or not, I have seen developers rely solely on Javascript to attach a stylesheet!! EDIT: So long as your site is accessible and readable with the default stylesheet, then accessibility is not going to be an issue. It might even be an idea, that if you are relying on Javascript switchers, to insert them dynamically when the DOM is ready. That way, Javascript disabled users won't be given the (redundant) option.
Last Blog Entry: The Google Misconception (Feb 3rd, 2008)
Last edited by Aso; Mar 31st, 2008 at 17:37. |
|
|||
|
Re: Resizing the Font through Buttons/Links?
Ok done I think!
Sorry for the delay. Like I said, I'm very new to webwork. Below is an example of a test page I made up. I post back the page to load up a new stylesheet and it should resize the text.
Thanks again to Mason and Aso for their helpful suggestions. Now onto a javascript alternative for those not silly enough to turn it off... |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding Links to buttons - problem | fourtheye246 | Flash & Multimedia Forum | 2 | Jun 13th, 2007 06:29 |
| resizing.... | jjgamepro17 | Web Page Design | 3 | Apr 18th, 2007 20:22 |
| help with fwd/backwrd buttons affecting other buttons | typeofdoug | Flash & Multimedia Forum | 5 | Feb 4th, 2007 03:48 |
| Buttons to update font style and colour help | Loobyt | JavaScript Forum | 4 | Jun 20th, 2006 20:55 |