How do I extract element ID from loaded page

179 views Asked by At

I have a project that loads some pages inside TembeddedWb. After the pages are loaded I want to grab the ID elements from some images. For example, I have an image like this inside the html page

<a href="#" style="cursor:pointer"><img id="image1" src='pathto/image1' border="0" style="display:inline" /></a>

How should I read the ID element when I click on this image inside tembeddedwb?

I tried something like this:

 var
  MousePos: TPoint;
  HtmlElement: IHTMLElement;
  iHTMLDoc: IHtmlDocument2;
edit.Text := edit.text + ' ' + HtmlElement.id;

Do I have to use Tpoint? What should I do?

1

There are 1 answers

2
DelphiStudent On BEST ANSWER

So i follow TLama comment and i done it here is what i did for future help for others

var
  MousePos: TPoint;
  HtmlElement: IHTMLElement;
  iHTMLDoc: IHtmlDocument2;
begin
  MousePos := Ewb.ScreenToClient(MousePos);
  HtmlElement := iHTMLDoc.ElementFromPoint(MousePos.X, MousePos.Y);
  if Assigned(HtmlElement) then
    showmessage('id');
end;