Increase Font Size Dynamically in Firefox
According to this article from Danny Goodman, you can’t use the .style property to determine style properties of an element if they not defined in the style attribute attached to the element (inline). If style propeties are defined internally or externally, i.e. defined by style or link tags, you have to use a window.getComputedStyle() method for Firefox or currentStyle property in IE. In this case Firefox returns font information in pixels, e.g. 14px or 18px. IE returns it as a term, e.g. large or small.
Having this information, it is possible to build a function that would increase element font size dynamically in Firefox:
function increaseFontSize(elem){
var compStyle = window.getComputedStyle(elem, "");
//For this method you have to supply style attribute information the way it is required for css.
var size = compStyle.getPropertyValue(’font-size’);
//remove px from the value
size = size.replace("px", "");
//define new larger size
size = parseInt(size)+2;
// set element style the Javascript way
elem.style.fontSize = size+"px";
}
