View Full Version : Idiot-proof text resizing
marynorn
10-25-2007, 02:02 PM
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++. :rolleyes:
jscheuer1
10-25-2007, 03:20 PM
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:
<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.
marynorn
10-26-2007, 08:04 AM
Thanks. And yes, I quite agree with you. Unfortunately, I was specifically told to include a text resize function, so... :rolleyes:
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.