How to get the color of a textnode
- 10 years ago
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