Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

298
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!