Click to make body text larger | JavaScript

Posted by Wayne on Stack Overflow See other posts from Stack Overflow or by Wayne
Published on 2010-05-25T17:09:43Z Indexed on 2010/05/25 17:11 UTC
Read the original article Hit count: 197

Filed under:
|
|
|
|

Please note this is just an example:

<img src="img/normal-font.png" onclick="javascript:document.body.style.fontSize = '13px';" /> &nbsp; 
<img src="img/medium-font.png" onclick="javascript:document.body.style.fontSize = '14px';" /> &nbsp; 
<img src="img/large-font.png"onclick="javascript:document.body.style.fontSize = '15px';" />

The body text does indeed enlarge if I choose one of them, but what I like to include is remembering what option you've chosen by reading cookies.

In fact, I have no experience in creating cookies in JS, only in PHP. Could someone come up with an example of how to make cookies the simpliest way remembering my option, but whenever someone clicks another one, it should get rid of the cookie that was last set, e.g. Cookie value has 15px, then should update it or remove it with a new cookie with a new value of 13px and so on.

Thanks :)

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about html