increase or decrease text size - A + A

Hello everyone,

I need a very simpe funtion on a webpage where people can increase or decrease the font size.
No heavy cookies or a giant ocean of java, just as simple as can be.
( - A + A)

I allready have this:

<script>
dom = (document.all || document.getElementById)?1:0;
function changeCss(obj,px) {
   if (dom) {
      if (document.all) doc = document.all;
      else doc = document.getElementById;
      doc(obj).style.fontSize=px+'px'
   }
   return false;
}
</script>

AND two buttons with small A and big A on the top of the page

 <a href="#" onClick="return changeCss('t',11)"><img border="0" src="lettersize_smaller.gif"></a></td>
                                <td width="14" height="33">
                                <a href="#" onClick="return changeCss('t',12)"><img border="0" src="lettersize_bigger.gif"></a></td>
                                <td width="98" height="33">

..... this function only allowe me to change from 11 px up to 12 px... but the page has all kinds of sizes
from big headlines, small imagetext to very small contact infos in the bottom...

... So what I need is to change the function so it increase / decrease the fonts in some kind of harmony like using % percent.

Do you know any way to change the script or a similar script which is very easy to use?
rrendermanAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
zkeownConnect With a Mentor Commented:
Generally you should define your font sizes in "em"s, as it makes font size on the browser and in your code much more easy & predictable.

I used a very similar method on CarolinaGrowl.com... look at the source of this page.  Notice the font sizing only affects a specific portion of the page as well.

http://www.carolinagrowl.com/Read.aspx?Story=488

0
 
R7AFCommented:
I don't see any A+ or A- on your page. Furthermore, if I press ctrl-+ all fonts get bigger, not just a portion of it. Still the concept is interesting.
0
 
zkeownCommented:
The font sizer is just below the headline and byline of the story...

Delicious | Print | Email | Font Size
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
R7AFCommented:
Sorry, totally missed that! It looks nice!
0
 
zkeownCommented:
Thanks!  Let me know if you have any questions on the implementation...  I might even remember how it works :)
0
 
zkeownCommented:
Just wondering if you ever had any luck.
0
 
Computer101Commented:
Forced accept.

Computer101
EE Admin
0
All Courses

From novice to tech pro — start learning today.