Jump to content

Tap


picyka

Recommended Posts

btnLinkAtendimento.JSInterface.JSAddListener('tap', 'function(sender, e, eOpts){window.open("https://api.whatsapp.com/send?phone=55' + lTelefone + '&text='+lTexto+'", "_blank")}');

 

Good morning, I currently run a call on the client side like this, I would like that, before triggering the tap, I could execute the click on the server side, would that be possible?

Link to comment
Share on other sites

31 minutes ago, picyka said:

btnLinkAtendimento.JSInterface.JSAddListener('tap', 'function(sender, e, eOpts){window.open("https://api.whatsapp.com/send?phone=55' + lTelefone + '&text='+lTexto+'", "_blank")}');

 

Good morning, I currently run a call on the client side like this, I would like that, before triggering the tap, I could execute the click on the server side, would that be possible?

Hello

Do you want to call window.open from serverside or just send an ajaxevent to server?

Link to comment
Share on other sites

1 minuto atrás, Hayri ASLAN disse:

Olá

Você deseja ligar para o window.open do serverside ou apenas enviar um evento ajaxevent para o servidor?

I wanted that, before executing the method on the client, I would be able to execute any server.

Link to comment
Share on other sites

1 hour ago, picyka said:

I wanted that, before executing the method on the client, I would be able to execute any server.

 


procedure TMainmForm.UnimButton1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='customTap' then
  begin
    UniSession.AddJS('window.open("https://api.whatsapp.com/send?phone=55123456", "_blank");')
  end;
end;

procedure TMainmForm.UnimFormCreate(Sender: TObject);
begin
  with UnimButton1, JSInterface do
  begin
    JSAddListener('tap', JSFunction('ajaxRequest('+JSName+', "customTap")'))
  end;
end;

 

Link to comment
Share on other sites

13 minutes ago, Hayri ASLAN said:

 


procedure TMainmForm.UnimButton1AjaxEvent(Sender: TComponent; EventName: string;
  Params: TUniStrings);
begin
  if EventName='customTap' then
  begin
    UniSession.AddJS('window.open("https://api.whatsapp.com/send?phone=55123456", "_blank");')
  end;
end;

procedure TMainmForm.UnimFormCreate(Sender: TObject);
begin
  with UnimButton1, JSInterface do
  begin
    JSAddListener('tap', JSFunction('ajaxRequest('+JSName+', "customTap")'))
  end;
end;

 

 

It almost worked, when you're on your cell phone, this method below doesn't work...

UniSession.AddJS('window.open("https://api.whatsapp.com/send?phone=55' + lTelefone + '&text='+lTexto+'", "_blank");');

 

from the desktop, it works.

Link to comment
Share on other sites

25 minutes ago, picyka said:

 

It almost worked, when you're on your cell phone, this method below doesn't work...

UniSession.AddJS('window.open("https://api.whatsapp.com/send?phone=55' + lTelefone + '&text='+lTexto+'", "_blank");');

 

from the desktop, it works.

As window.open opens a new tab, you're calling window.open indirectly (from server side), not in direct response to a user event(tap event).

Most browsers will block those calls. You should do your check inside tap event or you should use sync ajaxrequest.

Please refer below post for Sync ajaxrequest.

 

Link to comment
Share on other sites

49 minutes ago, Hayri ASLAN said:

À medida que o window.open abre uma nova guia, você está chamando window.open indiretamente (do lado do servidor), não em resposta direta a um evento do usuário (toque no evento).

A maioria dos navegadores bloqueará essas chamadas. Você deve fazer o seu check dentro do evento de toque ou você deve usar o ajaxrequest sincronizado.

Por favor, consulte abaixo o post para Sync ajaxrequest.

 

with btnLinkAtendimento, JSInterface do
        JSInterface.JSAddListener('tap', JSFunction('ajaxRequest('+JSName+', "customTap",[],false).responseText == ''true'''));

 

perfect.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...