简体   繁体   中英

react-native Android Webview trigger clicks

I'm trying to trigger clicks on WebViews and want to open them for example in a new WebView to make a route flow. In iOS I can call the method onShouldStartLoadWithRequest and look at the event like this:

onShouldStartLoadWithRequest(e) 
{ 
  if(e.navigationType === "click") 
  { 
  }     
}

On Android this function doesn't exists. Does someone know how to do something like this? Maybe you handle this in an other way but I really don't have a plan on this. Thanks for any advice

I solved this by routing the onNavigationStateChange function (which fires on Android), to my implementation of onShouldStartLoadingWithRequest :

onNavigationStateChange (req) {
  if (Platform.OS !== 'ios') {
    this.onShouldStartLoadWithRequest(req)
  }
}

And:

onNavigationStateChange={this.onNavigationStateChange} 

In this instance req contains the navigationType property. Remember to include Platform from react-native .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM