Test56
11 years agoContributor
Retrieving CSS property
Hello, I am using TC 9.3 version. I need to retrieve the web objects CSS properties. I am trying to retrieve it as a property of the web object, e.g. "aqObject.GetPropertyValue(webObject, pr...
- 11 years agoThere is sample code here: http://support.smartbear.com/viewarticle/62849/, but there is element variable missing in the IE 7-8 code path, so the correct code should be like that:
Function getStyle(element, styleProp)
Dim document, style
Set document = element.ownerDocument
If aqObject.IsSupported(document, "defaultView") Then
' Internet Explorer 9+, Firefox, Chrome, Safari, Opera
Set style = document.defaultView.getComputedStyle(element, "")
getStyle = style.getPropertyValue(styleProp)
Else
' Internet Explorer 7 - 8
getStyle = element.currentStyle.getPropertyValue(styleProp)
End If
End Function
When calling it you should not use "style." in styleProp parameter, just "fontSize" or some other property name.