Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2007
    Location
    Bristol
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the font size

    I'm currently looking at adding javascript to change the font size on a web page by clicking different links. I have found a script here which does the trick, however I was wondering how I would go about adding some more code so that I could have a link to put the text back to the default size?

  • #2
    New to the CF scene
    Join Date
    Feb 2007
    Location
    Bristol
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not to worry, I found another way of adjusting the text, using this code:

    Code:
    function txtSm() {
    	document.body.style.fontSize='70%';
    }
    
    function txtMed() {
    	document.body.style.fontSize='85%';
    }
    
    function txtLg() {
    	document.body.style.fontSize='100%';
    }
    and then applying an onclick event handler to an image/text.

  • #3
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    Quote Originally Posted by ninthofjune View Post
    however I was wondering how I would go about adding some more code so that I could have a link to put the text back to the default size?
    Use classes rather than style, so you will have a "default" value in a "default" class.
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*


  •  

    Posting Permissions

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