I know that most likely the answer is very obvious, but I've looked everywhere on the internet and I have not found anything. I use this method to see if the user presses on the WebView
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType; {
I can assure you that it works.
What I want to do is to make different actions according to the id
es
<a id="hello" href="..."><img src="..." /></a>
once the delegate detect "touch click" on the img with the "hello" id, I would do some custom stuff, like [self callSomething];
Could you show me how to do it using a sample code? thanks
change your code as follows
and in the delegate method try like this.
To achieve this you should put javascript onClick handler to any DOM element you need
f.e
On UIWebView delegate's method ignore links like above
There are benefits from my point of view:
Not associated with specific DOM element like
<a href=...>
, you can assign such handler to anything you needNot associated with html
id
attributeAbility inside
UIWebView
ignore loading such links and just execute your customSelector nativlyUIWebView
can't receive id from dom element but one thing you can do is pass value inhref
url with a parameterhello
like:and you can get parameter as: