Registriert seit: 14. Apr 2008
3.006 Beiträge
Delphi 2009 Professional
|
AW: Header auslesen/ ändern in TWebBrowser.OnBeforeNavigate2
18. Mär 2013, 13:04
Eine (vermutliche) Lösung ist hier zu finden:
http://stackoverflow.com/questions/9...wser-in-delphi
Delphi-Quellcode:
procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
NewHeaders: OleVariant;
begin
// do not allow frames or iframes to raise this event
if (pDisp as IUnknown) = (WebBrowser1.ControlInterface as IUnknown) then
begin
// avoid stack overflow: check if our custom header is already set
if Pos(' MyHeader', Headers) <> 0 then Exit;
// cancel the current navigation
Cancel := True;
(pDisp as IWebBrowser2).Stop;
// modify headers with our custom header
NewHeaders := Headers + ' MyHeader: Value'#13#10;
(pDisp as IWebBrowser2).Navigate2( URL, Flags, TargetFrameName, PostData, NewHeaders);
end;
end;
Michael Justin
|
|
Zitat
|