jfancy-Transport Canada wrote:
This code needs to be changed so that it is compatible with other
browsers like Opera, Netscape, and Mozilla.
{
s=a[i].currentStyle.fontSize+'';
s=Right(s,2);
a[i].style.fontSize = parseInt(a[i].currentStyle.fontSize)+factor+s;
}
In particular, the "currentStyle" and "style" i would imagine needs to
be changed to something and i'm not sure how to go about doing that.
Any Suggestions...?
I use a function to get a defined style of an element:
function getStyle(aElm, aStyle) {
var lStyle;
try {
if (aElm && typeof aElm.style != "undefined")
lStyle = aElm.style[aStyle];
}
catch(e) {}
var retVal;
if (lStyle)
retVal = lStyle;
else {
// Mozilla
if (document.defaultView) {
aStyle = aStyle.replace(/([A-Z])/g, "-$1").toLowerCase();
retVal =
aElm.ownerDocument.defaultView.getComputedStyle(aE lm,"").getPropertyValue(aStyle);
// some elements might not have a defined value (eg. images)
if (retVal == "auto") {
if (aStyle == "width")
retVal = aElm.offsetWidth;
else if (aStyle == "height")
retVal = aElm.offsetHeight;
}
}
// IE
else if (aElm.currentStyle) {
retVal = aElm.currentStyle[aStyle];
}
else
return null;
}
return retVal;
}
Your script block might then look like this (note, I don't know what
"Right" does and "factor" is so if you don't get it working, you might
show us some more code):
s = getStyle(a[i],"fontSize");
var s_new=Right(s,2);
a[i].style.fontSize = parseInt(s)+factor+s_new;
Daniel