Obliviux
Obliviux

Reputation: 11

How to check the URL of a WebView?

I have a Subview that load a Webview. In this Webview I load a file HTML locally in the Documents folder of my App. I need to check if the webview load another HTML file. Specifically:

  1. Webview load "index.html" locally in my Documents folder
  2. After 7 days a Javascript load another page with location.href= "index2.html",
  3. When I load this WebView I need to check if the current URL is index.html or index2.html, if is the second I must change Subview!

How can I do this?

Upvotes: 1

Views: 2174

Answers (3)

Sean
Sean

Reputation: 41

Use this NSURL method [NSURL fileURLWithPath:@"some/path/to/your/file" isDirectory:NO] and pass that to a NSURLRequest which is then passed to your UIWebView. You can get the path to your resource by using the [[NSBundle mainBundle] pathForResource...] methods.

Upvotes: 1

prakash
prakash

Reputation: 59719

NSURL *url = myWebView.request.URL;

Upvotes: 0

jnic
jnic

Reputation: 8785

NSString *currentUrl = [[[yourWebView request] URL] absoluteString];

Upvotes: 6

Related Questions