ExecuteJavaScript(WebBrowser:TWebBrowser; Code: string):Variant;
var //发送脚本
Document:IHTMLDocument2;
Window:IHTMLWindow2;
begin
// execute javascript in webbrowser
Document:=WebBrowser.Document as IHTMLDocument2;
if not Assigned(Document) then Exit;
Window:=Document.parentWindow;
if not Assigned(Window) then Exit;
try
Result:=Window.execScript(Code,‘JavaScript‘);
except
on E:Exception do raise Exception.Create(‘Javascript error ‘+E.Message+‘ in: ‘#13#10+Code);
end;
end;
时间: 2024-11-05 16:00:36