title: how to find the center/x,y coordinate of an image in UIWebView
body: <p>So I have a UIWebView which I have added a touch gesture in it, and I would like to find the x,y origin coordinates of an image tapped in the web view or if possible the center of the image in x y coordinates in the web view. The code I have is:</p>
  
  <pre><code>- (CGPoint) topLeftPointsForImage:(UIGestureRecognizer *)sender
  {
      CGPoint pt = [sender locationInView:self];
      NSString * offsetTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetTop", pt.x, pt.y
                            ];
  
      NSString * offsetLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).offsetLeft", pt.x, pt.y
                        ];
  
      NSString * scrollTop = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollTop", pt.x, pt.y
                                ];
  
      NSString * scrollLeft = [NSString stringWithFormat:@"document.elementFromPoint(%f, %f).parentNode.scrollLeft", pt.x, pt.y
                               ];
  
  
      float x = [[self stringByEvaluatingJavaScriptFromString:offsetTop] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollTop] floatValue];
      float y = [[self stringByEvaluatingJavaScriptFromString:offsetLeft] floatValue] - [[self stringByEvaluatingJavaScriptFromString:scrollLeft] floatValue];
      NSLog(@"Coor height is %f with coor width is %f", x, y);
  
      CGPoint point = CGPointMake(x, y);
      return point;
  }
  </code></pre>
  
  <p>However, this doesn't seem to give me a correct value. I am not a javascript master, so looking for some advice for this.</p>