Accessibility (contrast) via Javascript

0

I have a website that I have to have the following methods:

Increase font size, Decrease font size, Contrast.

I have already achieved the first two, I now need to contrast with pure javascript.

Has anyone done anything like this?

Preferably without using Jquery or another framework. An example I saw was in the link

But I could not reproduce just via javascript. Thanks.

    
asked by anonymous 29.09.2014 / 19:58

1 answer

1

"Just JavaScript" means without touching CSS? The simplest way seems to be to define the alternate style in CSS and associate it with a class that can be given to the body of the page.

For example, add this rule to your style sheet:

body.contraste {
    background: #000000;
}

And a button that runs the code:

var
    className = 'contraste',
    el = document.querySelector('body');
if (el.classList) {
    el.classList.add(className);
}
else {
    el.className += ' ' + className;
}

This is the beginning of a way to solve your problem. JavaScript code does not depend on any library framework. It works in current browsers and in IE from 8.

The logic of the solution is that there is a set of rules that style the page in "contrast mode" (whatever it is) and these rules are valid while the body of the page (the body element) has the contrast class. ..

    
29.09.2014 / 20:28