views:

339

answers:

1

I need to do something on each page change, before that page starts loading/executing.

First, I tried using -webView:shouldStartLoadWithRequest: but that won't work, because it's also called for XHR requests and iframe requests.

Second, I tried using -webViewDidStartLoad: and comparing webView.request to it's previous value, to see if it changed. This doesn't work, because webView.request is updated only some time after the call.

Any more ideas?

A: 

Make a Category or extend UIWebview that overrides loadRequest, doing your operation first and then doing the standard loadRequest.

David Sowsy
That won't work... the page can also be changed as a result of a 30x redirect, meta redirect, JS setting window.location, etc...
Jaka Jančar
Ah so you want to set up a filter on stringByEvaulatingJavaScriptFromString: or get more detailed data out of the DOM tree?
David Sowsy