-1

我有一个项目可以在 TembeddedWb 中加载一些页面。加载页面后,我想从一些图像中获取 ID 元素。例如,我在 html 页面中有这样的图像

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

当我在 tembeddedwb 中单击此图像时,我应该如何读取 ID 元素?

我试过这样的事情:

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

我必须使用 Tpoint 吗?我应该怎么办?

4

1 回答 1

0

所以我关注 TLama 评论,我在这里完成了我为未来帮助他人所做的事情

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;
于 2014-12-20T22:14:48.553 回答