Yazzmi
Yazzmi

Reputation: 1571

iphone app webview link action

Is there a way to make the action of clicking a link in a html of a UIWebView to load another UIView and pass the value of the url to that view, instead of loading that html page in the same UIWebView. So basically, modify the default action of clicking a link in a UIWebView. Is this possible?

Upvotes: 4

Views: 1433

Answers (2)

drawnonward
drawnonward

Reputation: 53689

In your UIWebViewDelegate do this:

- (BOOL)webView:(UIWebView *)webView
  shouldStartLoadWithRequest:(NSURLRequest *)request
  navigationType:(UIWebViewNavigationType)navigationType {

  if ( navigationType == UIWebViewNavigationTypeLinkClicked ) {
    // do something with [request URL]
    return NO;
  }
  return YES;
}

Upvotes: 6

Related Questions