Changing the font size with javascript - ΩJr. Software Articles and Products

This information lives on a web page hosted at the following web address: 'https://omegajunior.globat.com/code/'.

A.E.Veltstra
March 8, 2003

Use this javascript technique to allow your visitors to change the font size of your web pages, even in stubborn browsers.

Problem


The world's most distributed web browser refuses to allow a visitor to change the font size on the visited web page.


Solution


A script as used by this page. Copy it to your own web server and add it to your web pages. Adapt your style sheets (see below).


Why does it work?


Because we specified 2 kinds of rules for the letter heights in our style sheet:



Note


On iPad and possibly other mobile platforms that know zooming, scaling the font has an unexpected paradoxically opposite effect: it causes the page to zoom in or out.


Test it yourself:

[ Plus ]

[ Minus ]

Need problem solving?

Talk to me. Let's meet for coffee or over lunch. Mail me at “omegajunior at protonmail dot com”.