Page 1 of 1
text - bigger / smaller
Posted: Tue May 29, 2007 2:12 pm
by spamyboy
Code: Select all
function zoomText(Accion,Elemento){
obj=document.getElementById(Elemento);
if (obj.style.fontSize==""){
obj.style.fontSize="100%";
}
actual=parseInt(obj.style.fontSize);
incremento=10;
if(Accion=="reestablecer"){
obj.style.fontSize="100%"
}
if(Accion=="aumentar"){
valor=actual+incremento;
obj.style.fontSize=valor+"%"
}
if(Accion=="disminuir"){
valor=actual-incremento;
obj.style.fontSize=valor+"%"
}
}
How to make that it would be not possible to make text smaller then 70% and larger than 130% ?
Pleas help.
Posted: Tue May 29, 2007 2:23 pm
by feyd
Add checks against those sizes....
Posted: Tue May 29, 2007 2:28 pm
by spamyboy
Code: Select all
function zoomText(Accion,Elemento){
obj=document.getElementById(Elemento);
if (obj.style.fontSize==""){
obj.style.fontSize="100%";
}
actual=parseInt(obj.style.fontSize);
incremento=10;
if(Accion=="reestablecer") {
obj.style.fontSize="100%"
}
if (Accion=="aumentar") {
if (obj.style.fontSize<="130%"){
valor=actual+incremento;
obj.style.fontSize=valor+"%"
}}
if (Accion=="disminuir"){
if (obj.style.fontSize!="70%"){
valor=actual-incremento;
obj.style.fontSize=valor+"%"
}}
}
This one almost works, but still now, pleas help.
Posted: Tue May 29, 2007 2:45 pm
by superdezign
Why are you using != on 70%?
works
Posted: Tue May 29, 2007 2:46 pm
by spamyboy
Code: Select all
function zoomText(Accion,Elemento){
obj=document.getElementById(Elemento);
if (obj.style.fontSize==""){
obj.style.fontSize="100%";
}
actual=parseInt(obj.style.fontSize);
incremento=10;
if(Accion=="reestablecer") {
obj.style.fontSize="100%"
}
if (Accion=="aumentar") {
if (obj.style.fontSize!="130%"){
valor=actual+incremento;
obj.style.fontSize=valor+"%"
}}
if (Accion=="disminuir"){
if (obj.style.fontSize!="70%"){
valor=actual-incremento;
obj.style.fontSize=valor+"%"
}}
}
feyd | 
Posted: Tue May 29, 2007 2:51 pm
by superdezign
Haha, no no no. I was pointing out what you probably did wrong, not right.
What I think you want to do is: (this is pseudo code BTW)
if(fontSize > '130%') fontSize = '130%';
else if(fontSize < '70%') fontSize = '70%';
Right?
(Don't take that word for word... You'd have to parse the strings as integers first.)