WordPress.org

Ready to get started?Download WordPress

Forums

Change Font Size (3 posts)

  1. fr0s3in
    Member
    Posted 5 years ago #

    How do I give the reader three button to change the font size? I dont want CTRL + MouseWheel because it stretches everything.

  2. churchthemer
    Member
    Posted 5 years ago #

    Place this Javascript somewhere in the <head> </head> section of your header.php file:

    <script language="JavaScript" type="text/javascript">
    function changeFontSize(inc)
    {
      var p = document.getElementsByTagName('p');
      for(n=0; n<p.length; n++) {
        if(p[n].style.fontSize) {
           var size = parseInt(p[n].style.fontSize.replace("px", ""));
        } else {
           var size = 12;
        }
        p[n].style.fontSize = size+inc + 'px';
       }
    }
    </script>

    Then, where ever you want to place the controls add:

    <a href="javascript:changeFontSize(1)">Increase Font Size</a>
    <a href="javascript:changeFontSize(-1)">Decrease Font Size</a>

    You can link these too images as well.

    Hope that helps.

  3. fr0s3in
    Member
    Posted 5 years ago #

    thx so much! worked like a charm!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.