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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts

    make font size bigger w/out css?

    is it possible to make fonts size bigger without changing the css?

    I just want to let users to change the font size to bigger or smaller in one paragraph, not in others.

    For example 2 images: smaller and bigger and some code like that:

    onClick = this(<p></p>) -> font -> size -> set -> (default+1)

    and

    onClick = this(<p></p> -> font -> size -> set -> (default-1)


  • #2
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    &nbsp;........ another wild guess ........

  • #3
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Cheesebag. .

    I also found the following script here. The code is smarter for what I need so I tested it in IE, MOZ and OP and it works just fine.

    The problem is that I just need to increase/decrease the font size in one paragraph. Modifying the code I made it to work just for the <p> tags, but I need it to work only in the <p id="article">

    CODE:

    var firstCall = true;

    function changeFontsize(fSize, increment) {
    if (firstCall) {
    firstCall = false;
    if (increment != "")
    changeFontsize('70', '');
    }
    if (document.getElementsByTagName) {
    tag = "p";
    var getElement = document.getElementsByTagName(tag);
    var eachElement, currentFontSize, fontIncrease, newFontSize;
    for (i=0; i<getElement.length; i++) {
    eachElement = getElement[i];
    if (increment != "") {
    currentFontSize = parseInt(eachElement.style.fontSize);
    fontIncrease = parseInt(increment);
    newFontSize = currentFontSize + fontIncrease;
    }
    else if (fSize != "")
    newFontSize = parseInt(fSize);
    eachElement.style.fontSize = newFontSize + "%";
    setCookie('fontSize', newFontSize);
    }
    }
    }

    AND IN THE PAGE:

    <a href="javascript:changeFontsize('70', '');">default</a>
    <a href="javascript:changeFontsize('100', '');">bigger</a>

    Could you give me a hand?

  • #4
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Maybe...
    Code:
    function changeFontsize(fSize, increment, el_id) {
         if (firstCall) {
             firstCall = false;
         if (increment != "")
             changeFontsize('70', '');
       }
         var getElement;
         if (el_id)
             getElement = new Array(document.getElementById(el_id));
         else getElement = document.getElementsByTagName('p');
         var eachElement, currentFontSize, fontIncrease, newFontSize;
         for (i=0; i<getElement.length; i++) {
              eachElement = getElement[i];
              if (increment != "") {
                  currentFontSize = parseInt(eachElement.style.fontSize);
                  fontIncrease = parseInt(increment);
                  newFontSize = currentFontSize + fontIncrease;
          }
              else if (fSize != "")
                  newFontSize = parseInt(fSize);
         eachElement.style.fontSize = newFontSize + "%";
         setCookie('fontSize', newFontSize);
       }
    }
    <a href="javascript&#58;changeFontsize('70', '', 'article');">default</a>

    [untested]
    &nbsp;........ another wild guess ........

  • #5
    Regular Coder
    Join Date
    Feb 2003
    Posts
    345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Finally, this is all I wanted:

    function changeFontSize(fSize,id) {
    newFontSize = parseInt(fSize);
    document.getElementById(id).style.fontSize = newFontSize + "%";
    }

    <a href="javascript:changeFontSize('70','article');">default</a>
    <a href="javascript:changeFontSize('100','article');">bigger</a>

    <p id="article">bla bla bla</p>

    You're always there Cheesebag!

  • #6
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; viva el sacoconqueso !

    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;........ another wild guess ........

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That's "cheesebug" to the unenlightened.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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