请问一个webbrowser控件自动填表的有关问题
请教一个webbrowser控件自动填表的问题
大家好:
请教一个webbrowser控件自动填表的问题,网页代码如下
<input type="text" value="如生日、预约号码等" maxlength="11" onkeydown="" title="自定义号码" style="color: rgb(85, 85, 85); " onfocus=" if(this.style.color != '#555' ) { if (this.value == '如生日、预约号码等') { this.value = ''; } this.style.color = '#555'; } " onblur=" this.parentNode.childNodes[0].value = this.value; if(this.value == '') { this.value = '如生日、预约号码等'; this.style.color = '#c7c7c7'; }else { this.style.color = '#555'; }; ">
没有ID和NAME的TEXT控件,怎样赋值啊? 除了下面方法还有没有其它的?每次遍历一次,非常慢
procedure TForm1.Button4Click(Sender: TObject);
var
HtmlDoc:IHTMLDocument2;
myitem:Olevariant;
i:integer;
begin
myitem := WebBrowser1.Document;
for i := 0 to myitem.all.length - 1 do
begin
if Uppercase(myitem.all.item(i).type)='TEXT' then
begin
if Uppercase(myitem.all.item(i).name)='USERNAME' then myitem.all.item(i).value:='abc123';
end;
end;
end;
end;
------解决方案--------------------
把i写成一个常量值就快了!
------解决方案--------------------
最好是有ID和Name,沒有就只有循環了
或者你知道是第几个input,比如第2个,直接用item(2)
大家好:
请教一个webbrowser控件自动填表的问题,网页代码如下
<input type="text" value="如生日、预约号码等" maxlength="11" onkeydown="" title="自定义号码" style="color: rgb(85, 85, 85); " onfocus=" if(this.style.color != '#555' ) { if (this.value == '如生日、预约号码等') { this.value = ''; } this.style.color = '#555'; } " onblur=" this.parentNode.childNodes[0].value = this.value; if(this.value == '') { this.value = '如生日、预约号码等'; this.style.color = '#c7c7c7'; }else { this.style.color = '#555'; }; ">
没有ID和NAME的TEXT控件,怎样赋值啊? 除了下面方法还有没有其它的?每次遍历一次,非常慢
procedure TForm1.Button4Click(Sender: TObject);
var
HtmlDoc:IHTMLDocument2;
myitem:Olevariant;
i:integer;
begin
myitem := WebBrowser1.Document;
for i := 0 to myitem.all.length - 1 do
begin
if Uppercase(myitem.all.item(i).type)='TEXT' then
begin
if Uppercase(myitem.all.item(i).name)='USERNAME' then myitem.all.item(i).value:='abc123';
end;
end;
end;
end;
------解决方案--------------------
把i写成一个常量值就快了!
------解决方案--------------------
最好是有ID和Name,沒有就只有循環了
或者你知道是第几个input,比如第2个,直接用item(2)