我得到了tChromium在Delphi 7下工作,它应该都是一样的。
有我拿着从DOM
首先阅读元素,我从这个项目的包装步骤: https://code.google.com/p/delphichromiumembedded/downloads/detail?name=dcef-r306.7z&can=2&q=
还有一个XE2,也不会花费太多将其转换成XE3,如果您需要帮助,我会很乐意帮助请求。
然后宣布开始,并在tchromium
procedure TMainForm.crmLoadStart(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame); begin
if (browser <> nil) and (browser.GetWindowHandle = crm.BrowserHandle) and ((frame = nil) or (frame.IsMain)) then FLoading := True;
end;
结束,
procedure TMainForm.crmLoadEnd(Sender: TObject; const browser: ICefBrowser; const frame: ICefFrame; httpStatusCode: Integer; out Result: Boolean);
begin
if (browser <> nil) and (browser.GetWindowHandle = crm.BrowserHandle) and ((frame = nil) or (frame.IsMain)) then begin
FLoading := False;
// see if loaded
while(httpStatusCode <> 200) do begin
Application.ProcessMessages;
Sleep(50);
end;
browser.GetMainFrame.VisitDomProc(DomProc);
end;
end;
声明一个名为domproc像这样的过程:
procedure DomProc(const Doc: ICefDomDocument);
var
Node: ICefDomNode;
begin
url := Doc.BaseUrl;
if(url='www.goodwebsite.com') then // check if it is the right page and not add
Node := Doc.Body.Document.GetElementById('idofwhatyouarelookingfor');
Node.SetElementAttribute('value','Hello world :D');
end;
这是最可靠的方法我到目前为止,已经发现,你需要确保页面装载得很好,并且你得到了正确的dom t框架。
希望它可以帮助你,请务必查看上面的下载链接中的示例代码,这帮助我了很多。
玩得开心编码,Delphi岩石!
取决于您使用的Chromium版本。据我所知,在几个版本中,DOM迭代根本不起作用。 – TLama 2013-03-24 14:56:00
最新版本,从官方网站下载 – LuckyD 2013-03-24 15:07:44
如果我们在讨论['CEF1'](https://code.google.com/p/delphichromiumembedded/)封装(因为也有''CEF3'](https ://code.google.com/p/dcef3/)wrapper),那么恐怕你只是碰到了这个问题(同样的问题似乎发生在CEF3中)(https://code.google。 com/p/dcef3/issues/detail?id = 10)。你可以尝试一些旧版本的'CEF1'(不能告诉你哪个是最新的,哪里工作的),并检查自该版本以来发生了什么变化。 – TLama 2013-03-24 15:18:58