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

129
Views
Injecting different JavaScript based on the current page being viewed in WebView

Please tell me the correct way to inject specific JavaScript to the WebView depending on which page is currently being viewed in the WebView?

I want to show 2 steps. Step 1 is successful but when the WebView loads the second page the second step of JavaScript is not successful.

     const injectedJavaScript: = `
    let currentStep = "step1";
    if(currentStep === 'step1') {
      document.getElementById('username').value =  '${
        this.props.username
      }'; document.getElementById('password').value = '${
        this.props.password
      }'; document.getElementById('login').click();
      currentStep = 'step2';
    } else if(currentStep === 'step2' && window.location.href === "https://www.example.com") {
      currentStep = 'download';
      document.getElementsByClassName('button')[0].click();
    }
    `;
 <WebView
        ignoreSslError={true}
        source={{ uri: "https://www.example.com" }}
        style={{ marginTop: 20, height: 400, width: 400 }}
        injectedJavaScript={injectedJavaScript}
        javaScriptEnabledAndroid={true}
        onError={() => this.webviewError(e)}
        startInLoadingState={true}
        scalesPageToFit={true}
      />
about 4 years ago · Juan Pablo Isaza
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!