Jump to content
PavelX

onShouldStartLoadWithRequest alternate solutions for FMX.TWebBrowser

Recommended Posts

Hi,

 

As you may know the onShouldStartLoadWithRequest is not working with FMX.TWebBrowser on Windows and Linux platforms.

Is OK with Android and MacOS

 

A bug report has been filled a long time  (5 years ago)  and reported again and again

https://quality.embarcadero.com/browse/RSP-11206 27/May/15 2:08 AM

https://quality.embarcadero.com/browse/RSP-24414/May/19 2:34 AM

the actual status is " Unresolved" without any other reply or solution

 

For me  this event is very useful when I try to execute a delphi function from the web browser (javascript)

 

 

EX:

==== HTML / JAVASCRIPT BROWSER


<div id="fresult"></div>
<button type="button" onclick="callDelphi()">Call delphi function</button>


<script>

function callDelphi(){

    window.location.href='https://www.fake.com/?func=HiDelphi';

}


function setResult(dresult){

   document.getElementById('fresult').innerHTML=dresult;

}


</script>


==== DELPHI UNIT


procedure TForm1.wb_ViewShouldStartLoadWithRequest(ASender: TObject; const URL: string);
begin

    if pos('www.fake',url)>0 then
    begin

         wb_View.Stop; /// IMPORTANT here we stop the browser

         if pos('HiDelphi',URL)>0 then

           wb_View.EvaluateJavaScript('setResult('' Hi from Delphi  '')');

   end;

end;

 

 

I am just wondering if you have another solution to call a delphi function from FMX TWebBrowser (a cross platform solution)

The example is working only with Android and MacOS .

 

For Windows I have used Chromium FMX (another web browser component from https://github.com/salvadordf/CEF4Delphi)

I need one source code for multiple platforms and at this moment this is not possible because of this bug

 

Did you know how to create/modify/use other strategy with FMX.TWebBrowser to achieve this? - stop the browser before load/process any URL?

 

Thank you in advance.

 

 

 

 

 

Edited by PavelX

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×