Delphi 如何从加载的页面中提取元素ID
我有一个在TembeddedWb中加载一些页面的项目。加载页面后,我想从一些图像中获取ID元素。例如,我在html页面中有这样一个图像Delphi 如何从加载的页面中提取元素ID,delphi,tembeddedwb,Delphi,Tembeddedwb,我有一个在TembeddedWb中加载一些页面的项目。加载页面后,我想从一些图像中获取ID元素。例如,我在html页面中有这样一个图像 <a href="#" style="cursor:pointer"><img id="image1" src='pathto/image1' border="0" style="display:inline" /></a> 我必须使用Tpoint吗?我该怎么办 所以我跟随特拉玛的评论,我在这里做了这件事,这是我为将来帮助他
<a href="#" style="cursor:pointer"><img id="image1" src='pathto/image1' border="0" style="display:inline" /></a>
我必须使用Tpoint吗?我该怎么办 所以我跟随特拉玛的评论,我在这里做了这件事,这是我为将来帮助他人所做的
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;
IHTMLDocument2
接口具有此方法。请停止说“它不工作”。还请描述某件事情是如何失败的。已经回答了并且成功了。13小时前!我为未来提供建议。如果你继续说“它不工作”,你将不会取得应有的进展。你是对的,感谢你的建议和更正。只要浏览器的内容不可滚动,也不可滚动到其他地方,这将起作用。如果是这样的话,你应该在计算的客户端鼠标位置上添加文档的滚动偏移量。谢谢你的评论对我帮助很大
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;