Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you are using <a href="http://docwiki.embarcadero.com/VCL/en/SHDocVw.TWebBrowser" rel="nofollow"><code>TWebBrowser</code></a> then the <a href="http://docwiki.embarcadero.com/VCL/en/SHDocVw.TWebBrowser.Stop" rel="nofollow"><code>TWebBrowser.Stop</code></a> or if you want <a href="http://msdn.microsoft.com/en-us/library/aa768272%28v=vs.85%29.aspx" rel="nofollow"><code>IWebBrowser2.Stop</code></a> is the right function suited for this purpose. Try to do this little test and see if it stops the navigation to your page (if the navigation takes more about 100ms of course :)</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); begin Timer1.Enabled := False; WebBrowser1.Navigate('www.example.com'); Timer1.Interval := 100; Timer1.Enabled := True; end; procedure TForm1.Timer1Timer(Sender: TObject); begin if WebBrowser1.Busy then WebBrowser1.Stop; Timer1.Enabled := False; end; </code></pre> <p>If you are talking about <a href="http://www.bsalsa.com/" rel="nofollow"><code>TEmbeddedWB</code></a> then take a look at the <code>WaitWhileBusy</code> function instead of waiting for <code>ReadyState</code> change. As the only parameter you must specify the timeout value in milliseconds. Then you can handle the <code>OnBusyWait</code> event and interrupt the navigation if needed.</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); begin // navigate to the www.example.com EmbeddedWB1.Navigate('www.example.com'); // and wait with WaitWhileBusy function for 10 seconds, at // this time the OnBusyWait event will be periodically fired; // you can handle it and increase the timeout set before by // modifying the TimeOut parameter or cancel the waiting loop // by setting the Cancel parameter to True (as shown below) if EmbeddedWB1.WaitWhileBusy(10000) then ShowMessage('Navigation done...') else ShowMessage('Navigation cancelled or WaitWhileBusy timed out...'); end; procedure TForm1.EmbeddedWB1OnBusyWait(Sender: TEmbeddedWB; AStartTime: Cardinal; var TimeOut: Cardinal; var Cancel: Boolean); begin // AStartTime here is the tick count value assigned at the // start of the wait loop (in this case WaitWhileBusy call) // in this example, if the WaitWhileBusy had been called in // more than 1 second then if GetTickCount - AStartTime &gt; 1000 then begin // cancel the WaitWhileBusy loop Cancel := True; // and cancel also the navigation EmbeddedWB1.Stop; end; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload