Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

delphi webbrowser: how to prevent or hide that javascript error?

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.
like image 801
yarek Avatar asked Mar 07 '13 16:03

yarek


1 Answers

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;
like image 87
TLama Avatar answered Nov 08 '22 03:11

TLama