Getting URL From UIWebView

NSString *currentURL = myWebView.request.URL.absoluteString;
NSLog(@"%@", currentURL);


// or you can get requested pages link before loading page starts if you set your webview's delegate and implement webView:shouldStartLoadWithRequest:navigationType method

-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
    NSString *requestedLink = [[[webView request] URL] absoluteString];
    NSLog(@"%@",requestedLink);
    return YES;
}

No comments:

Post a Comment