Hello all,
I have UIWebView loaded with an HTML file. I want to know the position (means x and y cordinates) of an HTML element on the screen when the webview is loaded.
Thanks in advance
Hello all,
I have UIWebView loaded with an HTML file. I want to know the position (means x and y cordinates) of an HTML element on the screen when the webview is loaded.
Thanks in advance
You may need to a combination of JavaScript and Objective-C to achieve this. You need a JavaScript functino to pass back the screen position of certain element, and then translate that position to the screen on the iPhone.
- (NSString *)stringByEvaluatingJavaScriptFromString:(NSString *)script
One way is to write a JavaScript that takes an element ID and returns its position and the screen resolution. Then translate that to the webview resolution on iPhone screen. It gets trickier if the user is allowed to zoom and pan the webview though.