title: Delphi and FireMonkey WebBrowser Callback using file://
body: <p>I am using 10.2.2 Tokyo Enterprise and FireMonkey's <code>TWebBrowser</code> in an App. I wish to receive a callback response, but I don't receive a URL back when the <code>ShouldStartLoadWithRequest</code> fires when I run my code.</p>
  
  <p>I would like to know if this is possible without writing a wrapper. I feel I have missed something simple. </p>
  
  <p>I have checked these sites and many more and have tried many different ways...</p>
  
  <p><a href="https://stackoverflow.com/questions/30046303/">Callback from Firemonkey WebBrowser JavaScript code</a></p>
  
  <p><a href="http://delphiworlds.com/2013/11/adding-javascript-processing-capability-to-twebbrowser-in-ios/" rel="nofollow noreferrer">Adding Javascript processing capability to TWebBrowser in iOS</a> </p>
  
  <p><a href="https://stackoverflow.com/questions/23416086/">Callback Delphi function from TWebBrowser by javascript on Delphi XE6 for all platforms (including iOS, ANDROID)?</a></p>
  
  <p>Here is my simple code version:</p>
  
  <p>index.html</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;&lt;html lang="en"&gt;
  &lt;body&gt;
  &lt;h2&gt; Get Callback&lt;/h2&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <pre class="lang-pascal prettyprint-override"><code>procedure TForm2.FormCreate(Sender: TObject);
  begin
    WebBrowser1.URL := 'file://' + GetCurrentDir +  '/../../index.html';
  end;
  
  procedure TForm2.Button1Click(Sender: TObject);
  var
    js : string;
  begin
    js := ' var url = "file://' + GetCurrentDir +  '/../../index.html";'+
          'var encodedurl = encodeURIComponent(url);'+
          'window.location.href = encodedurl+"?67";';
    WebBrowser1.EvaluateJavaScript(js);
  end;
  
  procedure TForm2.WebBrowser1ShouldStartLoadWithRequest(ASender: TObject;
    const URL: string);
  var
    js,TheURL: String;
  begin
    TheURL := 'file://' + GetCurrentDir +  '/../../index.html';
    js := URL;
    Fetch(js, TheURL+'?',true,false);  //remove the URL and ?
    js := TIdURI.URLDecode(js, IndyTextEncoding_UTF8);
    Memo1.Lines.Text := js;
  end;
  </code></pre>
  
  <p>Changing the end of the URL should, in principle, trick the WebBrowser into believing that it is a new URL, and I should be able to extract the number 67 while still keeping the page refreshed. </p>
  
  <p>Please can you point me in the right direction?</p>