OnTranslateUrl
This function is called before loading
a URL to allow you an opportunity to modify the URL.
In the following example the user
is only allowed access to local stored files. If a link to an
internet-site is clicked, we want a file "DontDoThis.htm"
to be shown.
uses
comobj;
function
TForm1.EmbeddedWB1TranslateUrL(const dwTranslate:
Cardinal;
const pchURLIn: PWideChar; var ppchURLOut:
PWideChar): HRESULT;
begin
if Pos('file:///',pchURLIn) = 0 then
ppchURLOut := StrToPLOleStr('DontDoThis.htm');
end;
|
Similar lines of code could also have
been placed in OnBeforeNavigate2 but there is an important
difference: OnTranslateUrl is not called when you use Navigate or
Navigate2 but only when a hyperlink is clicked. So in this
example you could still let a speedbutton call EmbeddedWb1.Go('www.somewhere.com')
without redirecting the user to "DontDoThis.htm".