揽
揽月
Unregistered / Unconfirmed
GUEST, unregistred user!
怎样在WebBrowser打开的网页的输入框中填写一个字符串?
我写了如下的程序,iELC.length的值为零,不知是哪里不对。
procedure TLoginForm.FormShow(Sender: TObject);
var
IDoc1: IHTMLDocument2;
iELC: IHTMLElementCollection;
HtmlInputEle2: IHtmlTextAreaElement;
spDisp: IDispatch;
i: Integer;
begin
WebBrowser1.Navigate(ExtractFilePath(Application.ExeName)+'URRP/Login.htm');
WebBrowser1.Document.QueryInterface(IHTMLDocument2, IDoc1);
if IDoc1 <> nil then
begin
iELC := IDoc1.all;
for i:=0 to iELC.length-1 do
begin
spDisp := iELC.item(i,0);
if SUCCEEDED(spDisp.QueryInterface(IHtmlTextAreaElement,HtmlInputEle2))then
begin
if UPPERCASE(HtmlInputEle2.name) = 'USERNAME' then
HtmlInputEle2.value := 'Admin'
end;
end;
end;
end;
我写了如下的程序,iELC.length的值为零,不知是哪里不对。
procedure TLoginForm.FormShow(Sender: TObject);
var
IDoc1: IHTMLDocument2;
iELC: IHTMLElementCollection;
HtmlInputEle2: IHtmlTextAreaElement;
spDisp: IDispatch;
i: Integer;
begin
WebBrowser1.Navigate(ExtractFilePath(Application.ExeName)+'URRP/Login.htm');
WebBrowser1.Document.QueryInterface(IHTMLDocument2, IDoc1);
if IDoc1 <> nil then
begin
iELC := IDoc1.all;
for i:=0 to iELC.length-1 do
begin
spDisp := iELC.item(i,0);
if SUCCEEDED(spDisp.QueryInterface(IHtmlTextAreaElement,HtmlInputEle2))then
begin
if UPPERCASE(HtmlInputEle2.name) = 'USERNAME' then
HtmlInputEle2.value := 'Admin'
end;
end;
end;
end;