Hey again, another JS problem.
I need a way to increase the font size of some text on the fly. I can not use font tags. How do I do this?
increasing font size
Moderator: General Moderators
- CoderGoblin
- DevNet Resident
- Posts: 1425
- Joined: Tue Mar 16, 2004 10:03 am
- Location: Aachen, Germany
Only ways I know of... If the text is all in one element you can set the element class to be something else defined by CSS to be larger. If not (and you state you cannot use the font element) make it a span with a css style. If the font style is to change (onmouseout etc) you would then potentially have to remove the span (moving the contents out) when the mouse moves out.
Re: increasing font size
Put selectors (id's or classes) on the elements containing the text you need to increase the font size for.shiznatix wrote:Hey again, another JS problem.
I need a way to increase the font size of some text on the fly. I can not use font tags. How do I do this?
Then use css to change the font size on those elements.
- shiznatix
- DevNet Master
- Posts: 2745
- Joined: Tue Dec 28, 2004 5:57 pm
- Location: Tallinn, Estonia
- Contact:
thanks for the input. I found this realy handy script online:
Code: Select all
//font sizes
var szs = new Array( 'xx-small','x-small','small','medium','large','x-large','xx-large' );
//default size (small)
var startSz = 2;
function ts(trgt, inc)
{
//if you can't get elements, just quit the function
if (!document.getElementById)
return
var d = document, cEl = null, sz = startSz, i, j, cTags;
sz += inc;
if ( sz < 0 )
sz = 0;
if ( sz > 6 )
sz = 6;
startSz = sz;
if (!(cEl = d.getElementById(trgt)))
cEl = d.getElementsByTagName(trgt)[0];
cEl.style.fontSize = szs[ z];
for (i = 0 ; i < tgs.length ; i++)
{
cTags = cEl.getElementsByTagName(tgs[i]);
for (j = 0; j < cTags.length; j++)
cTags[j].style.fontSize = szs[sz];
}
}-
darryladie
- Forum Commoner
- Posts: 62
- Joined: Thu Mar 02, 2006 6:14 pm
- Location: East Sussex, UK
Why scrap that and try this:
http://www.dyn-web.com/dhtml/sizefont/index.php
I have used it in the past it's pretty good if you're using CSS.
http://www.dyn-web.com/dhtml/sizefont/index.php
I have used it in the past it's pretty good if you're using CSS.