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

300
Visualizações
React Native Web view click detection

has anyone worked with web view click detection feature? Have a web view loading a site where I need to detect the click by user on a button. I tried using injected javascript but couldn't achieve the desired result. Here is my code

<WebView scalesPageToFit
    startInLoadingState
    originWhitelist={['*']}
    style={{ flex: 1 }} source={{ uri: url  }}
    javaScriptEnabled={true}
    domStorageEnabled={true}
    setSupportMultipleWindows={false}
    /> 

How will we add support for click event ? Do we need to change backend or we can handle on front end ?

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

0

I solved the issue with below code. This is working for me and detecting click inside html :

import { WebView } from 'react-native-webview';

export default function App() {

const html = `
 <html>
   <body style='color:red'>
     This is a test
     <input type="button" value="Click me" onclick="msg()">
     <script>
         function msg() {
           setTimeout(function () {
             window.ReactNativeWebView.postMessage("Hello!")
           }, 2000)
         }
       </script>
   </body>
 </html>
 `;

return (
 <View style={styles.container}>
   <StatusBar style="auto" />
   <WebView
       source={{ html }}
       style={{width:400,height:200,backgroundColor:'white',marginTop:20}}
       onMessage={event => {
         alert(event.nativeEvent.data);
       }}
     />
 </View>
);
}


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