TWebBrowser问题(100)

  • 主题发起人 主题发起人 WilliamGui
  • 开始时间 开始时间
W

WilliamGui

Unregistered / Unconfirmed
GUEST, unregistred user!
用WebBrowser实现打开google点击搜索,第一次正常,再点击就不行,怎么回事代码如下:function TfrmMain.OpenWebPage(pSearchEngine: TSearchEngine; pSearchContent: string; pPageNo: integer): boolean; //WebBrowser动作:打开搜索引擎首页 function WB_OpenSearchEngine(pURL: string; pWebBrowser: TWebBrowser): boolean; begin result:=false; if trim(pURL)='' then exit; if pWebBrowser=nil then exit; if pWebBrowser.Busy then pWebBrowser.Stop; try pWebBrowser.Navigate(pURL); except exit; end; result:=true; end;var vURL: string; vWebBrowser: TWebBrowser; vWBDoc:IHTMLDocument2; vWBSearchContentName, vWBSearchBtnName: string; vWBSearchContent:IHtmlInputElement; vWBSearchBtn:OleVariant;begin result:=false; case pSearchEngine of Google: begin vURL:=SearchEngineURL_Google; vWBSearchContentName:='q'; vWBSearchBtnName:='btnG'; vWebBrowser:=wbGoogle; if not WB_OpenSearchEngine(vURL, vWebBrowser) then exit; while vWebBrowser.busy do begin Application.ProcessMessages; end; vWBDoc:=vWebBrowser.document as IHTMLDocument2; vWBSearchContent:=(vWBDoc.all.item(vWBSearchContentName,0) as ihtmlinputelement); vWBSearchContent.value:=vWBSearchContent.value+edtSearchContent.Text; vWBSearchBtn:=vWBDoc.all.item(vWBSearchBtnName,0); vWBSearchBtn.click; end; Baidu: begin
 
在按钮中调用这方法,第一次正常搜索,第二次搜索不了,google输入框空白
 

Similar threads

A
回复
0
查看
981
Andreas Hausladen
A
S
回复
0
查看
579
SUNSTONE的Delphi笔记
S
S
回复
0
查看
674
SUNSTONE的Delphi笔记
S
A
回复
0
查看
964
Andreas Hausladen
A
I
回复
0
查看
528
import
I
后退
顶部