uses
mshtml,activex;
function TForm1.wr(b: Twebbrowser; s: string): bool;
var
d: IHTMLDocument2;
a: Variant;
begin
b.Navigate('about:blank');
try
d:=b.document as IHTMLDocument2;
a := VarArrayCreate([0,0],varVariant);
a[0] := s;
d.write(PSafeArray(TVarData(a).VArray));
d:=nil;
except
messagebox(handle,'无法正常写入代码!','错误',mb_ok+mb_iconerror);
end;
end;