6

I am running TEmbeddedwb and I got a javascript timeout error while navigating on that TEmbeddedwb .

(I do not have this error while running in my internet explorer !)

enter image description here

The browser asks me if I want to stop the execution of the script.

I put the TEmbeddedwb propertioes to

silent = true

dialogoBox.disableAll = true

But I still have this popup comming out !

1) why do I have this error (tested on 2pcs) while there is no error while navigating on Internet explorer

2) how to disable / hide this popup ?

regards

    unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw_EWB, EwbCore, EmbeddedWB;

type
  TForm1 = class(TForm)
    iemain: TEmbeddedWB;
    procedure iemainScriptError(Sender: TObject; ErrorLine, ErrorCharacter,
      ErrorCode, ErrorMessage, ErrorUrl: String;
      var ScriptErrorAction: TScriptErrorAction);
    procedure FormCreate(Sender: TObject);
  private
    { Déclarations privées }
  public
    { Déclarations publiques }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.iemainScriptError(Sender: TObject; ErrorLine,
  ErrorCharacter, ErrorCode, ErrorMessage, ErrorUrl: String;
  var ScriptErrorAction: TScriptErrorAction);
begin
       MessageDlg('hello', mtWarning, [mbOK], 0);
       if ErrorCode='123' then    ScriptErrorAction := eaContinue;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    iemain.Navigate('http://www.expedia.fr/Hotels');
end;

end.
yarek
  • 11,278
  • 30
  • 120
  • 219
  • To answer your first question you need to provide the link to the page you're navigating to. – TLama Mar 07 '13 at 17:28
  • So you see the `MessageDlg` or not? – kobik Mar 07 '13 at 19:14
  • I can not reproduce. The page redirects to 'https://....' and then it asks if I want to see non-securily delivered content. Whether I answer yes or no the page displays and responds as expected. I think you need to give more details about what settings you might have different from 'normal', whatever that is. – Tom Brunberg Jan 16 '16 at 16:54

1 Answers1

5

How to handle JavaScript error in TEmbeddedWB ?

Write a handler for the OnScriptError event and return one of the available TScriptErrorAction values in the ScriptErrorAction output parameter. To ignore the script error and continue use e.g.:

procedure TForm1.EmbeddedWB1ScriptError(Sender: TObject; ErrorLine,
  ErrorCharacter, ErrorCode, ErrorMessage, ErrorUrl: string;
  var ScriptErrorAction: TScriptErrorAction);
begin
  if ErrorCode = 123 then
    ScriptErrorAction := eaContinue;
end;
TLama
  • 75,147
  • 17
  • 214
  • 392
  • +1, I wonder if the browser will actually stop the execution of the script (or maybe it will hang?). – kobik Mar 07 '13 at 18:54
  • 2
    I Just added that event, and put a breapoint in EmbeddedWB1ScriptError and it never goes there ! It displays the error directly and EmbeddedWB1ScriptError is not called at all ! – yarek Mar 07 '13 at 19:06