Dieses Codestück habe ich aus meinem Projekt SpamRevenge rausgerissen
und ungetestet umgeschrieben:
Delphi-Quellcode:
procedure ClearWebForm(WebBrowser: TWebBrowser; submit:Boolean);
var
i,j:Integer;
FormItem, Element : OleVariant;
document : OleVariant;
itemtype, itemname : string;
begin
document := WebBrowser.OleObject.document;
//no forms on document
If document.all.tags('FORM').length=0 then
begin
exit;
end;
//count forms on document
for I:=0 to document.forms.Length -1 do
begin
FormItem := document.forms.Item(I);
For j:= 0 to FormItem.Length-1 do
begin
Element := FormItem.Item(j);
itemname := Element.Name;
itemtype := UpperCase(Element.Type);
if (itemtype = 'TEXT') then
begin
maxlen := Element.MaxLength;
Element.Value:= '';
end else if (itemtype = 'RADIO') then
begin
Element.Checked := False;
end
else
Element.value := Null;
end;
end;
end;