...

View Full Version : make font size bigger w/out css?



maltrecho
09-24-2003, 06:58 PM
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)

:thumbsup:

cheesebag
09-24-2003, 07:13 PM
http://www.dyn-web.com/dhtml/sizefont.html

maltrecho
09-24-2003, 08:58 PM
Thanks Cheesebag. :thumbsup:.

I also found the following script here (http://kussatz.com/gurus/javascript_font_size_changers.html). 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?

cheesebag
09-24-2003, 09:18 PM
Maybe...


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]

maltrecho
09-25-2003, 04:57 AM
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! :thumbsup: :thumbsup: :thumbsup:

cheesebag
09-25-2003, 05:53 AM
&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;&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;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;http://www.irongate.co.nz/mwdata/confectionery/webpages/images/cheese.jpg

whammy
09-25-2003, 06:22 AM
That's "cheesebug" to the unenlightened. ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum