how to intercept Button click inside UIWebview on IOS?

You can do the following:

In your HTML

<a class="yourButton" href="https://stackoverflow.com/questions/10992339/inapp://capture">Button Text</a>

In your UIWebViewDelegate

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
   if ([request.URL.scheme isEqualToString:@"inapp"]) {
      if ([request.URL.host isEqualToString:@"capture"]) {
         // do capture action
      }  
      return NO;
   }  
   return YES;
}

I added “capture” to your button’s URL so that you could distinguish between several buttons that should trigger different actions (if you want to):

Leave a Comment