Solved
Forum Discussion
royd
Regular Contributor
Hi Robert,
As you suggested, I am using IE 11. Now I am getting runtime error:
JavaScript runtime error.
TypeError: Cannot read property 'color' of null
TypeError: Cannot read property 'color' of null
If you take a look at the above screenshot, the style (color) in named 'backgroud-color'. I am using the following to Log the color:
var style = page.contentDocument.defaultView.getComputedStyle(colorPrimary, ""); Log.Message(style.background-color);I am not quite sure if I should be using
Log.Message(style.background-color);
or
Log.Message(style.color);
Either way, I am getting the same error.
Thank you.
royd
6 years agoRegular Contributor
I used:
var style = page.contentDocument.defaultView.currentStyle.backgroundColor(colorPrimary, "")
as you suggested.
I am getting:
JavaScript runtime error.
TypeError: Cannot read property 'backgroundColor' of undefined
TypeError: Cannot read property 'backgroundColor' of undefined
- tristaanogre6 years agoEsteemed Contributor
backgroundColor is not a method, it's the actual property. So, just compare that property to the desired value.
- royd6 years agoRegular Contributor
Hi Robert
Sorry for delayed response. It took me a while but finally figured it out. Thanks for pointing me to right direction. This is what finally worked:
var previewColor = previewSwatch.ownerDocument.defaultView.getComputedStyle(previewSwatch, "").backgroundColor;
- TanyaYatskovska6 years agoSmartBear Alumni (Retired)
- royd6 years agoRegular Contributor
Hi Robert
Thank you for the clarification. :)
- TanyaYatskovska6 years agoSmartBear Alumni (Retired)
Hi royd,
Could you please mark the answer that help you as a solution? You see a big green "Accept as Solution" button next to it. It will help other community members who will face a similar situation. Thanks.
Related Content
- 11 years agoRyan_Moran