How to get the color of a textnode
I have a question about the colort of a textnode. Please look at the following two textnodes. I am trying to achieve their color by using the following code:
var pin7= Aliases.home.panel1.textnodePin7;
var cc= pin7.style.color;
var bc= pin7.style.backgroudcolor;
But I always get the empty string for the colors? Which function is correct for achieving their colors?
Solved! Go to Solution.
Not that simple usually I'm afraid.
The colours are likey part of a stylesheet? (CSS layer)
It's this you need to interpret in order to get the colours in use. And you'll sometimes find that different browsers report CSS differently. (I forget exactly how. But I have a feeling it may be transparencies or something? I certainly remember hitting a few differences between IE and Chrome.)
And you may also find you run into transparencies in order to allow the colour from a object layered below it to show through.
And sometimes that may be conditional. (ie - sometimes it will be transparent, sometimes not, depending on the logic in the code)
And you may also have an opacity setting to factor in. (How see-through, or not, something is.)
Here is the code I need to use (VBScript) to get the colour info back from the last web application I was working on:
object_backgroundcolour = <OBJECT>.ownerDocument.defaultView.getComputedStyle(<OBJECT>, "").backgroundColor
Thank you very much! With your help, I get the background color of the textnode. I found the example function for achieving the css attribute from smartbear webseite. And it works very well.
function getStyle(element, styleProp)
var document = element.ownerDocument;
if (aqObject.IsSupported(document, "defaultView"))
// Internet Explorer 9+, Firefox, Chrome, Opera
var style = document.defaultView.getComputedStyle(element, "");
// Internet Explorer 7 - 8
var backgroundColor = getStyle(myTextNode, "background-color");