views:

600

answers:

2

Hey guys,

I already tried getting the current url of my UIWebView with: webview.request.URL. Unfortunately the NSURL was empty. Anything wrong here? I'am working with Xcode 3.2.2 beta 5.

The code above should be executed in the UIWebViews delegate didStartLoad...

Thanks a lot!

+1  A: 

You could try this:

NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:@"window.location"];
Rengers
Thanks. My code above works when executing in didFinishLoad....Somewhere I've read that the js version doesn't work on every page.But I'll try.
rdesign
A: 

window.location via JS didn't work reliably for me, but this did:

currentURL = currentWebView.request.URL.absoluteString;

Credit: http://mohrt.blogspot.com/2008/10/getting-url-from-uiwebview.html

Matt Andersen