Search code examples
javascriptusabilityaccessibility

What is the "best practice" for resizing text with Javascript?


What is the "best practice" (accessibility/usability-wise) for resizing text with Javascript?

My current solution is that for when the user clicks the resize link it adds an extra class to the body tag.

It also sets a cookie and then when the page is loaded - onLoad() - it reads the cookie and reapplys the body class tag again if needs be.

The only thing not ideal is that it loads then applys - the previous solution was to edit the CSS file before the page loaded but that threw up security warnings if the CSS file was in a different directory.

So, essentially is my solution reasonable or is there a better way?

Adam


Solution

  • Your solution sounds fine, with one addition: you can read the cookie as the page loads and add the class to the body element while the markup is generated. Most server-side languages support this: PHP, JSP, RoR etc. Other than that, you have a solid solution.