Delphi: Error 80020101 when running javascript in Twebbrowser

Asked

Viewed 2,356 times

1

I use the TWebbrowser in an application Delphi XE7, but I’m having trouble trying to execute commands javascript.

(Oleexception ... Unable to complete operation Error: 80020101 )

This happens with any function that I try to execute, be it my or jquery for example, it seems that the function is not even executed. The procedure I use to perform is as follows: How to call Javascript functions in a Twebbrowser from Delphi in my case, I have the function:

        function colaNota () {

        $('#corpo').append($('<div id="' + new_nota_id + '">' + new_nota_bar + '<p>' + new_nota_texto + '</p><div/>').addClass('notas ui-widget-content').css({
            left: new_nota_x,
            top: new_nota_y }));

        controlaBarraMensagens('oculto');          
        $( ".notas" ).draggable();
        $("#corpo").removeClass("inserindo");
        $("#sub_indice_mold").removeClass("visivel");
        clearNota();
    };

In Delhi I’m calling it that:

JSFn := 'colaNota();';  //Assim não funciona
JSFn := 'alert("Assim funciona");';

HTMLWindow.execScript(JSFn, 'JavaScript');
  • edits the question and posts one of the functions

2 answers

1

A way to solve this:

      Try
          WebBrowser1.Silent :=True;
          //seu código aqui

      Except
        On E:Exception Do Begin
          MessageDlg('Houve um erro ao lentar ler o arquivo : '+E.Message,mtInformation,[mbOK],0);
        End;
     end;
  • Just to wrap up, this error was happening because the functions were not visible to Delphi as they were within $(Document). ready

1

This type of error occurred to me as well. And the way to eliminate it was by correcting Javascript as it seemed to be in error. Type No JS was like this ( umavar = 10;) but it should be a function call and not a var and when I did this ( umavar(10);) the JS was right and stopped giving error, described above.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.