Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
How to return value from InAppBrowser to Ionic app

We are loading given URL in the inappbrowser from ionic app, which will load HTML form along with one hidden input field.

I am trying to get that hidden field value while tapping submit button using inappbrowser's executeScript method as follow:

  browser.executeScript({
      code:
        "var result; document.getElementById('BtnSubmit').addEventListener('click', function(){" +
        "result = document.getElementById('myInput').value;});",
    });

In result variable, input value is fetched but need to return that from executeScript into ionic app context.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

You need to attach your response to message event of inappbrowser and then receive it on app side.

The below script is to send postmessage. It has particular format in which it gets passed. Need to create JSON object.

browser.executeScript({
code: "document.getElementById('customBackbtn').onclick = function() {\
var message = 'close';\
var messageObj = {message: message};\
var stringifiedMessageObj = JSON.stringify(messageObj);\
webkit.messageHandlers.cordova_iab.postMessage('stringifiedMessageObj');\
}"});

Then capture the post message from iab back in your app:

browser.on('message').subscribe((val)=>{
const postObject:any = val;

//Do whatever you want to with postObject response from inappbrowser

});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda