have a weird behaviour. In a UIWebView I have a javacript function to detect the postion of an element. this one:
function getPosition(element){
var el = element;
var pos = [el.offsetLeft, el.offsetTop];
var parent = el.offsetParent;
if (parent != el) {
while (parent) {
pos[0] += parent.offsetLeft;
pos[1] += parent.offsetTop;
parent = parent.offsetParent;
}
}
//alert(pos);
return pos;
}
nothing special… but when I call the function like that:
NSString *position = [browserWebView stringByEvaluatingJavaScriptFromString:@"getPosition(document.getElementById('exampleElement'));"];
I get an empty NSString back. When I insert an alert into the function (which is uncomment right now) I get the correct position in the alert!!
Why do I not get the value back and getting just an empty string when the correct return value pos seems to be there?