Lifelesspeople.com

 Forum FAQsForum FAQs  Knowledge BaseKnowledge Base  RulesRules   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   HostingHosting   RegisterRegister 
 DonateDonate   WikiWiki   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Font-size changer?

 
Lifelesspeople.com Forum Index -> Web Architects' Abode
Post new topic   Reply to topic View previous topic :: View next topic  
Author Message
agkamerer
Forum Regular


Joined: 08 Mar 2005
Posts: 396
Location: Alabama, USA

PostPosted: Wed Apr 09, 2008 7:39 pm    Post subject: Font-size changer? Reply with quote

I've seen this feature on blogs a few times, and I think it'd be a useful one to add to my webnovel, as it would allow readers to change the font size to suit their tastes. Yes, I know they could do it themselves through the browser controls, but I like the idea of an on-site button they could use.

What I'm looking for is something that provides a button that allows the user to either increase or decrease the font of a post (preferably, just the content of a blog post, not the rest of the site) instantly. I'm fairly certain it's done with AJAX.

I use wordpress for my webnovel, so if anyone knows of a plugin that gives this capability, I'd love to see it.

Thanks a lot. Smile
_________________
Gloria Fidelis: A Steampunk Fantasy
Back to top
 
krt
...


Joined: 11 Jan 2005
Posts: 4607
Location: Australia

PostPosted: Thu Apr 10, 2008 12:12 am    Post subject: Reply with quote

It's done in JS:

JavaScript:
Code:
function changeFontSize(amount) {

    var ele = document.getElementsByTagName('body')[0].style;

    if (!ele.fontSize) ele.fontSize = '75%';

    var newAmount = Math.round((ele.fontSize.subs_tring(0, ele.fontSize.length-1)) * (1+(amount/2/100)));

    ele.fontSize = Math.round(newAmount) + '%';

}

NOTE: In the above, remove the underscore (_) in subs_tring, the paranoid filters here don't allow that word Silly

And the HTML for the decrease/increase links:
Code:

<a href="javascript:changeFontSize(-10);" style="font-size: 100%;">A</a>
<a href="javascript:changeFontSize(100/9);" style="font-size: 125%;">A</a>


I don't see how you thought it would be AJAX though, are you sure you know what AJAX is and what it is for? The only possible application of it here that I can think of is something that re-calculates character widths but even that would be stored statically.
Back to top
 
Display posts from previous:   
Post new topic   Reply to topic    Lifelesspeople.com Forum Index -> Web Architects' Abode All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Home | Hosting | News | Forum | Links | System Status | About | Archive | Donate ]
Powered by phpBB © 2001, 2002 phpBB Group
All trademarks and copyrights on this page are owned by their respective owners. Posts and comments are owned by the poster. Everything else © 2001 - 2007 Lifelesspeople.com