2

I am using the class TEmbeddedWB to Access HTML elements in an embedded Web Browser in a Delphi program.

After much googling I can't come up with a solution for the following issue: How to directly read style properties of objects?

I tried:

Event.srcElement.getAttribute('style', 0)

and it returns (in CodeSite Live Viewer) [object MSStyleCSSProperties]

 Event.srcElement.getAttribute('style.display', 0)

returns an empty string (but in the code it is defined as block). I guess, this ominous object can be accessed some way to read the declared (or computed?) CSS properties; but I can't figure out how it can be achieved. To what type of variable should I assign the return value of getAttribute('style', 0)? Will the result be as declared or as computed?

There is no type MSStyleCSSProperties declared.

Any help would be appreciated.

I am a Delphi beginner. Sorry if this question is nooby.

Liglo App
  • 3,719
  • 4
  • 30
  • 54
  • 1
    If you downvote be so kind to describe the reason; the question is in my opinion well-written and clear. – Liglo App Jan 28 '15 at 17:12
  • 3
    It would make it easier for people to help you if you could show a simple example of the HTML you are working on, and the code you have. – David Heffernan Jan 28 '15 at 19:59

2 Answers2

2

The IHTMLElement has a property named style which is a IHTMLStyle object, and that object has some useful methods and properties that can help you.

Check this out:

Tag:IHTMLElement; // <div style="display: none;">

Memo1.Lines.Add(Tag.style.cssText); //Outputs "display: none;"
Memo1.Lines.Add(Tag.style.display); //Outputs "none"
Fenistil
  • 3,734
  • 1
  • 27
  • 31
-1

You should assign the return value of getAttribute function to a string:

var
StyleProperty     : string;

StyleProperty := Event.srcElement.getAttribute('style', 0);
securecodeninja
  • 2,497
  • 3
  • 16
  • 22
  • No, it's wrong. As I already have written, the return value after such an assignment is `[object MSStyleCSSProperties]`. – Liglo App Jan 30 '15 at 09:46