Forum Discussion
ArtemS
Alumni
15 years agoHello,
The style attributes obtained via the Object.style property contain only the attributes applied directly to the given web page element. They do not take account of the attributes inherited from the parent elements.
To get the resulting style attributes in InternetExplorer, the Object.currentStyle property is applied. Mozilla's analogue of this property is the getComputedStyle() method. You were absolutely right. Unlike IE, the method is available only for the window object and accepts the needed element as a parameter. The following snippet demonstrates how to use this method:
The style attributes obtained via the Object.style property contain only the attributes applied directly to the given web page element. They do not take account of the attributes inherited from the parent elements.
To get the resulting style attributes in InternetExplorer, the Object.currentStyle property is applied. Mozilla's analogue of this property is the getComputedStyle() method. You were absolutely right. Unlike IE, the method is available only for the window object and accepts the needed element as a parameter. The following snippet demonstrates how to use this method:
function GetStyleObj (page, elementID)
{
var element, ComputedStyle;
if (Options.Web.TreeModel == "DOM")
{
//Obtain the element in DOM model
element = page.document.getElementById(elementID);
}
else
{
//Obtain the element in Tag, Tree and Hybrid models
element = page.contentDocument.getElementById(elementID);
}
ComputedStyle = page.content.getComputedStyle(element, "");
return ComputedStyle;
}
function main()
{
var resultingStyle, page;
....
page = Aliases.firefox.Page("www.mysite.com")
resultingStyle = GetStyleObj (page, 'soughtElementID')
Log.Message("Font weight = "+resultingStyle.fontWeight);
...
}