1

I want to get the url of the link when it is clicked in UIWebView .

I am using this code

  NSString *currentURL = [NSString stringWithFormat:@"%@", webview.request.URL.absoluteString];

        NSLog(@"Current URL == %@",currentURL);

It gives me null

Current URL == (null)
ios
  • 955
  • 1
  • 12
  • 35
  • Possible duplicate of [iPhone - UIWebview - Get the URL of the link clicked](http://stackoverflow.com/questions/4679378/iphone-uiwebview-get-the-url-of-the-link-clicked) – johny kumar Nov 19 '15 at 12:25

1 Answers1

1

Try this In Webview Method :

     - (BOOL) webView: (UIWebView *) webView shouldStartLoadWithRequest: (NSURLRequest *) request navigationType: (UIWebViewNavigationType) navigationType{
             NSURL *url = request.URL;
             NSLog(@"%@", url.absoluteString);
            NSURL *url = request.URL;
            NSLog(@"%@", url.absoluteString);
            if ([url.host containsString:@"www.google.co.in"])
            {
               nslog(@"Google")
            }else{
            }
}
Maulik Patel
  • 397
  • 4
  • 15