Delphi: Error 80020101 when executing javascript in TWebbrowser

1

I use TWebbrowser in an application Delphi XE7 , but I'm having problems trying to execute javascript commands.

  

(OleException ... Can not complete the operation Error: 80020101)

This happens with any function I try to run, either mine or jquery for example, it seems the function does not even execute. The procedure I use to run 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 delphi I'm calling it like this:

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

HTMLWindow.execScript(JSFn, 'JavaScript');
    
asked by anonymous 07.11.2015 / 20:33

2 answers

1

One way to resolve 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;
    
09.11.2015 / 03:03
1

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

08.09.2016 / 12:20