Results 1 to 3 of 3

Thread: Idiot-proof text resizing

  1. #1
    Join Date
    Oct 2007
    Posts
    43
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Idiot-proof text resizing

    I'm looking for a simple 'increase text size' - 'decrease text size' script so people can resize text with one mouse click instead of having to Ctrl++.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Idiot-proof text resizing is an oxymoron. You can easily change the font-size for the page, but this approach requires that the page's font sizes are all dependant upon the base font-size for the page. If you have a page like that, it is so easy for the user to avail themselves of their browser's text-size options (either via hot key or a couple of clicks), that it is rather pointless to make up code specifically for that. Any code that you did use would be unavailable in some browsers anyway.

    But, it has been my experience that most folks won't take no for an answer, so:

    Code:
    <script type="text/javascript">
    function textSize(d){
    textSize.base+=d? 20 : -20;
    textSize.base=Math.max(textSize.base, 20);
    textSize.base=Math.min(textSize.base, 200);
    document.body.style.fontSize=textSize.base+'%';
    }
    textSize.base=100;
    if(document.body&&document.body.style)
    document.write('<input type="button" value="Text Size +" onclick="textSize(1);"> <input type="button" value="Text Size -" onclick="textSize(0);">');
    </script>
    You can put the above in the body of your page, wherever you would like the + and - buttons to appear.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Oct 2007
    Posts
    43
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default

    Thanks. And yes, I quite agree with you. Unfortunately, I was specifically told to include a text resize function, so...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •