<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: elementFromPoint() under iOS 5</title>
	<atom:link href="http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/</link>
	<description>iCab related stuff; Mac, iPhone and Cocoa programming</description>
	<lastBuildDate>Mon, 17 Jun 2013 14:36:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-25414</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Sat, 07 Apr 2012 17:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-25414</guid>
		<description><![CDATA[@Manu
You mean in iCab Mobile? No there&#039;s no password for the filters itself. But you can set a password for the whole App (In the &quot;Privacy/Access Control&quot; settings).]]></description>
		<content:encoded><![CDATA[<p>@Manu<br />
You mean in iCab Mobile? No there&#8217;s no password for the filters itself. But you can set a password for the whole App (In the &#8220;Privacy/Access Control&#8221; settings).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manu</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-25411</link>
		<dc:creator>Manu</dc:creator>
		<pubDate>Sat, 07 Apr 2012 16:17:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-25411</guid>
		<description><![CDATA[Is it possible to create a password for the Filters (Blocked Sites) ?]]></description>
		<content:encoded><![CDATA[<p>Is it possible to create a password for the Filters (Blocked Sites) ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thm</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20950</link>
		<dc:creator>thm</dc:creator>
		<pubDate>Fri, 10 Feb 2012 09:45:15 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20950</guid>
		<description><![CDATA[Thanks a lot, works perfectly!]]></description>
		<content:encoded><![CDATA[<p>Thanks a lot, works perfectly!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Benny</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20585</link>
		<dc:creator>Benny</dc:creator>
		<pubDate>Tue, 31 Jan 2012 09:06:08 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20585</guid>
		<description><![CDATA[Thanks.
That is a good and clear explanation.]]></description>
		<content:encoded><![CDATA[<p>Thanks.<br />
That is a good and clear explanation.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20216</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Fri, 20 Jan 2012 13:49:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20216</guid>
		<description><![CDATA[@max
Sorry, but I&#039;m not really sure what exactly you&#039;re doing with the navigation bar. Adding a navigation bar as subview to UIWebView will not shift the web page down so the top of the web page would be still located where it was located before, so the navigation bar is now overlapping and hiding parts of the web page. But it seems that according to your description the web page was shifted down by the navigation bar, and scrolling up by 44 px (the height of the navigation bar), the navigation bar is now out of view and the web page will directly start at the top of the screen. Is this what you wanted to say?
 
In general, adding a navigation bar as a subview of UIWebView won&#039;t make the navigation bar scroll at all, so you must have done something else if you can scroll the navigation bar along with the web page. I guess you&#039;ve  added the navigation bar as subview to one of the internal private subviews of UIWebView. In case this is what you&#039;ve done, please note that this is not really conforming to the AppStore guidelines. Using private APIs or private internal structures is not something you are supposed to do. Maybe this was also part of your problem?
Maybe all the coordinates you&#039;re working with are therefore wrong, maybe offset by the height of the navigation bar.

In any case, you might send me a complete Xcode project by email, so I can see your problem myself. Posting code fragments here probably doesn&#039;t help, because there&#039;s always missing something that is important. And the Navigation bar seems to be something that is important to fully understand your problem.]]></description>
		<content:encoded><![CDATA[<p>@max<br />
Sorry, but I&#8217;m not really sure what exactly you&#8217;re doing with the navigation bar. Adding a navigation bar as subview to UIWebView will not shift the web page down so the top of the web page would be still located where it was located before, so the navigation bar is now overlapping and hiding parts of the web page. But it seems that according to your description the web page was shifted down by the navigation bar, and scrolling up by 44 px (the height of the navigation bar), the navigation bar is now out of view and the web page will directly start at the top of the screen. Is this what you wanted to say?</p>
<p>In general, adding a navigation bar as a subview of UIWebView won&#8217;t make the navigation bar scroll at all, so you must have done something else if you can scroll the navigation bar along with the web page. I guess you&#8217;ve  added the navigation bar as subview to one of the internal private subviews of UIWebView. In case this is what you&#8217;ve done, please note that this is not really conforming to the AppStore guidelines. Using private APIs or private internal structures is not something you are supposed to do. Maybe this was also part of your problem?<br />
Maybe all the coordinates you&#8217;re working with are therefore wrong, maybe offset by the height of the navigation bar.</p>
<p>In any case, you might send me a complete Xcode project by email, so I can see your problem myself. Posting code fragments here probably doesn&#8217;t help, because there&#8217;s always missing something that is important. And the Navigation bar seems to be something that is important to fully understand your problem.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20194</link>
		<dc:creator>max</dc:creator>
		<pubDate>Fri, 20 Jan 2012 00:27:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20194</guid>
		<description><![CDATA[@alexander
Thanks for the explanation! but still lost. i know they are two different codes, what i don&#039;t get it how to get the returned point or how to use the javascript above. i have code working fine on my ios5 device in my app. my problem is i added a uinavigationbar as a subview to the web view.. so if i see the navigation bar, then any link clicked won&#039;t work. if i scroll down so i can&#039;t see it so the actual page is actually starts at the top line, then the links work again. i put a all this code into the javascript file. so now where do i put code to get the returned values? i kept the javascript code with x and y. but in the objective c class I&#039;m coding in on the web, i was using %i and stuff to see how to get a value. could never get any. so can you please show how to get the actual returned points so even when my navigation is showing i can  see it? heres some of my code:
&lt;pre&gt;
JSTools.js
==============

function MyAppGetHTMLElementsAtPoint(x,y) {
    var tags = &quot;,&quot;;
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.tagName) {
            tags += e.tagName + &#039;,&#039;;
        }
        e = e.parentNode;
    }
    return tags;
}

function MyAppGetLinkSRCAtPoint(x,y) {
    var tags = &quot;&quot;;
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.src) {
            tags += e.src;
            break;
        }
        e = e.parentNode;
    }
    return tags;
}

function MyAppGetLinkHREFAtPoint(x,y) {
    var tags = &quot;&quot;;
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.href) {
            tags += e.href;
            break;
        }
        e = e.parentNode;
    }
    return tags;
}

function documentCoordinateToViewportCoordinate(x,y) {
    var coord = new Object();
    coord.x = x - window.pageXOffset;
    coord.y = y - window.pageYOffset;
    return coord;
}

function viewportCoordinateToDocumentCoordinate(x,y) {
    var coord = new Object();
    coord.x = x + window.pageXOffset;
    coord.y = y + window.pageYOffset;
    return coord;
}

function elementFromPointIsUsingViewPortCoordinates() {
    if (window.pageYOffset &gt; 0) {     // page scrolled down
        return (window.document.elementFromPoint(0, window.pageYOffset + window.innerHeight -1) == null);
    } else if (window.pageXOffset &gt; 0) {   // page scrolled to the right
        return (window.document.elementFromPoint(window.pageXOffset + window.innerWidth -1, 0) == null);
    }
    return false; // no scrolling, don&#039;t care
}

function elementFromDocumentPoint(x,y) {
    if (elementFromPointIsUsingViewPortCoordinates()) {
        var coord = documentCoordinateToViewportCoordinate(x,y);
        return window.document.elementFromPoint(coord.x,coord.y);
    } else {
        return window.document.elementFromPoint(x,y);
    }
}

function elementFromViewportPoint(x,y) {
    if (elementFromPointIsUsingViewPortCoordinates()) {
        return window.document.elementFromPoint(x,y);
    } else {
        var coord = viewportCoordinateToDocumentCoordinate(x,y);
        return window.document.elementFromPoint(coord.x,coord.y);
    }
}

DLWebViewController - Just a view controller
======================

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        CGPoint point = [gestureRecognizer locationInView:web];
        
        // convert point from view to HTML coordinate system
        CGSize viewSize = [web frame].size;
        CGSize windowSize = [web windowSize];
        

        CGFloat f = windowSize.width / viewSize.width;
        if ([[UIDevice currentDevice].systemVersion doubleValue] &gt;= 5.) {
            point.x = point.x * f;
            point.y = point.y * f;
        } else {
            // On iOS 4 and previous, document.elementFromPoint is not taking
            // offset into account, we have to handle it
            CGPoint offset  = [web scrollOffset];
            point.x = point.x * f + offset.x;
            point.y = point.y * f + offset.y;
        }
        
        
        // Load the JavaScript code from the Resources and inject it into the web page
        NSString *path = [[NSBundle mainBundle] pathForResource:@&quot;JSTools&quot; ofType:@&quot;js&quot;];
        NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
        [web stringByEvaluatingJavaScriptFromString: jsCode];
        
        NSString *tPoint = [web stringByEvaluatingJavaScriptFromString:@&quot;viewportCoordinateToDocumentCoordinate(x,y);&quot;];
        NSLog(@&quot;test: %@&quot;,tPoint);
        
        // get the Tags at the touch location
        NSString *tags = [web stringByEvaluatingJavaScriptFromString:
                          [NSString stringWithFormat:@&quot;MyAppGetHTMLElementsAtPoint(%i,%i);&quot;,(NSInteger)point.x,(NSInteger)point.y]];
        
        NSString *tagsHREF = [web stringByEvaluatingJavaScriptFromString:
                              [NSString stringWithFormat:@&quot;MyAppGetLinkHREFAtPoint(%i,%i);&quot;,(NSInteger)point.x,(NSInteger)point.y]];
        
        NSString *tagsSRC = [web stringByEvaluatingJavaScriptFromString:
                             [NSString stringWithFormat:@&quot;MyAppGetLinkSRCAtPoint(%i,%i);&quot;,(NSInteger)point.x,(NSInteger)point.y]];
        
        
        NSString *url = nil;
        if ([tags rangeOfString:@&quot;,IMG,&quot;].location != NSNotFound) {
            url = tagsSRC;
        }
        if ([tags rangeOfString:@&quot;,A,&quot;].location != NSNotFound) {
            url = tagsHREF;
        }
        NSLog(@&quot;url : %@&quot;,url);
        
        NSArray *urlArray = [[url lowercaseString] componentsSeparatedByString:@&quot;/&quot;];
        NSString *urlBase = nil;
        if ([urlArray count] &gt; 2) {
            urlBase = [urlArray objectAtIndex:2];
        }
        
        if ((url != nil) &amp;&amp;
            ([url length] != 0)) {
            // Release any previous request
            [req release], req = nil;
            // Save URL for the request

===================
&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>@alexander<br />
Thanks for the explanation! but still lost. i know they are two different codes, what i don&#8217;t get it how to get the returned point or how to use the javascript above. i have code working fine on my ios5 device in my app. my problem is i added a uinavigationbar as a subview to the web view.. so if i see the navigation bar, then any link clicked won&#8217;t work. if i scroll down so i can&#8217;t see it so the actual page is actually starts at the top line, then the links work again. i put a all this code into the javascript file. so now where do i put code to get the returned values? i kept the javascript code with x and y. but in the objective c class I&#8217;m coding in on the web, i was using %i and stuff to see how to get a value. could never get any. so can you please show how to get the actual returned points so even when my navigation is showing i can  see it? heres some of my code:</p>
<pre>
JSTools.js
==============

function MyAppGetHTMLElementsAtPoint(x,y) {
    var tags = ",";
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.tagName) {
            tags += e.tagName + ',';
        }
        e = e.parentNode;
    }
    return tags;
}

function MyAppGetLinkSRCAtPoint(x,y) {
    var tags = "";
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.src) {
            tags += e.src;
            break;
        }
        e = e.parentNode;
    }
    return tags;
}

function MyAppGetLinkHREFAtPoint(x,y) {
    var tags = "";
    var e = document.elementFromPoint(x,y);
    while (e) {
        if (e.href) {
            tags += e.href;
            break;
        }
        e = e.parentNode;
    }
    return tags;
}

function documentCoordinateToViewportCoordinate(x,y) {
    var coord = new Object();
    coord.x = x - window.pageXOffset;
    coord.y = y - window.pageYOffset;
    return coord;
}

function viewportCoordinateToDocumentCoordinate(x,y) {
    var coord = new Object();
    coord.x = x + window.pageXOffset;
    coord.y = y + window.pageYOffset;
    return coord;
}

function elementFromPointIsUsingViewPortCoordinates() {
    if (window.pageYOffset &gt; 0) {     // page scrolled down
        return (window.document.elementFromPoint(0, window.pageYOffset + window.innerHeight -1) == null);
    } else if (window.pageXOffset &gt; 0) {   // page scrolled to the right
        return (window.document.elementFromPoint(window.pageXOffset + window.innerWidth -1, 0) == null);
    }
    return false; // no scrolling, don't care
}

function elementFromDocumentPoint(x,y) {
    if (elementFromPointIsUsingViewPortCoordinates()) {
        var coord = documentCoordinateToViewportCoordinate(x,y);
        return window.document.elementFromPoint(coord.x,coord.y);
    } else {
        return window.document.elementFromPoint(x,y);
    }
}

function elementFromViewportPoint(x,y) {
    if (elementFromPointIsUsingViewPortCoordinates()) {
        return window.document.elementFromPoint(x,y);
    } else {
        var coord = viewportCoordinateToDocumentCoordinate(x,y);
        return window.document.elementFromPoint(coord.x,coord.y);
    }
}

DLWebViewController - Just a view controller
======================

if (gestureRecognizer.state == UIGestureRecognizerStateBegan) {
        CGPoint point = [gestureRecognizer locationInView:web];
        
        // convert point from view to HTML coordinate system
        CGSize viewSize = [web frame].size;
        CGSize windowSize = [web windowSize];
        

        CGFloat f = windowSize.width / viewSize.width;
        if ([[UIDevice currentDevice].systemVersion doubleValue] &gt;= 5.) {
            point.x = point.x * f;
            point.y = point.y * f;
        } else {
            // On iOS 4 and previous, document.elementFromPoint is not taking
            // offset into account, we have to handle it
            CGPoint offset  = [web scrollOffset];
            point.x = point.x * f + offset.x;
            point.y = point.y * f + offset.y;
        }
        
        
        // Load the JavaScript code from the Resources and inject it into the web page
        NSString *path = [[NSBundle mainBundle] pathForResource:@"JSTools" ofType:@"js"];
        NSString *jsCode = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
        [web stringByEvaluatingJavaScriptFromString: jsCode];
        
        NSString *tPoint = [web stringByEvaluatingJavaScriptFromString:@"viewportCoordinateToDocumentCoordinate(x,y);"];
        NSLog(@"test: %@",tPoint);
        
        // get the Tags at the touch location
        NSString *tags = [web stringByEvaluatingJavaScriptFromString:
                          [NSString stringWithFormat:@"MyAppGetHTMLElementsAtPoint(%i,%i);",(NSInteger)point.x,(NSInteger)point.y]];
        
        NSString *tagsHREF = [web stringByEvaluatingJavaScriptFromString:
                              [NSString stringWithFormat:@"MyAppGetLinkHREFAtPoint(%i,%i);",(NSInteger)point.x,(NSInteger)point.y]];
        
        NSString *tagsSRC = [web stringByEvaluatingJavaScriptFromString:
                             [NSString stringWithFormat:@"MyAppGetLinkSRCAtPoint(%i,%i);",(NSInteger)point.x,(NSInteger)point.y]];
        
        
        NSString *url = nil;
        if ([tags rangeOfString:@",IMG,"].location != NSNotFound) {
            url = tagsSRC;
        }
        if ([tags rangeOfString:@",A,"].location != NSNotFound) {
            url = tagsHREF;
        }
        NSLog(@"url : %@",url);
        
        NSArray *urlArray = [[url lowercaseString] componentsSeparatedByString:@"/"];
        NSString *urlBase = nil;
        if ([urlArray count] &gt; 2) {
            urlBase = [urlArray objectAtIndex:2];
        }
        
        if ((url != nil) &amp;&amp;
            ([url length] != 0)) {
            // Release any previous request
            [req release], req = nil;
            // Save URL for the request

===================
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20182</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Thu, 19 Jan 2012 18:50:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20182</guid>
		<description><![CDATA[Please make sure that you understand that we&#039;re dealing with two different types of code: Objective-C and JavaScript. You can&#039;t directly call Objective-C from within  JS and vice versa. Also elements of one language does not work in another language. So for example
NSLog() does not work for debugging JavaScript. Also when using placeholders like %i, you have to make sure that you replace these by the real values within your Objective-C code. Within the JS code this won&#039;t work.  

There&#039;s only one way to execute JavaScript code from within Objective-C code, and this is through the method &quot;stringByEvaluatingJavaScriptFromString:&quot; of UIWebView, which expects the JavaScript code as string, and which will return the result of the last expression in the JavaScript code as string. 

You can use this to &quot;inject&quot; any JavaScript code into a web page, by passing in a string with the definition of the functions. Once injected, you can call these injected functions with different parameters multiple times. But in all cases, the code has to be the final one, so all placeholders of a Objective-C string (like %i, %@ etc) must be already replaced with their correct values, because within JavaScript these placeholders don&#039;t have any meaning.

Also make sure that the JavaScript code is correctly included in your X-Code project, otherwise when you try to load it, it may fail any you try to pass an empty string to the web page instead of your code. This is a common issue many developers have when they start  programming with JS for UIWebView, because by Xcode by default treats the JS code as &quot;code&quot; and not as &quot;resource&quot;, but in order to get this working, it must be treated as &quot;resource&quot;.]]></description>
		<content:encoded><![CDATA[<p>Please make sure that you understand that we&#8217;re dealing with two different types of code: Objective-C and JavaScript. You can&#8217;t directly call Objective-C from within  JS and vice versa. Also elements of one language does not work in another language. So for example<br />
NSLog() does not work for debugging JavaScript. Also when using placeholders like %i, you have to make sure that you replace these by the real values within your Objective-C code. Within the JS code this won&#8217;t work.  </p>
<p>There&#8217;s only one way to execute JavaScript code from within Objective-C code, and this is through the method &#8220;stringByEvaluatingJavaScriptFromString:&#8221; of UIWebView, which expects the JavaScript code as string, and which will return the result of the last expression in the JavaScript code as string. </p>
<p>You can use this to &#8220;inject&#8221; any JavaScript code into a web page, by passing in a string with the definition of the functions. Once injected, you can call these injected functions with different parameters multiple times. But in all cases, the code has to be the final one, so all placeholders of a Objective-C string (like %i, %@ etc) must be already replaced with their correct values, because within JavaScript these placeholders don&#8217;t have any meaning.</p>
<p>Also make sure that the JavaScript code is correctly included in your X-Code project, otherwise when you try to load it, it may fail any you try to pass an empty string to the web page instead of your code. This is a common issue many developers have when they start  programming with JS for UIWebView, because by Xcode by default treats the JS code as &#8220;code&#8221; and not as &#8220;resource&#8221;, but in order to get this working, it must be treated as &#8220;resource&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20180</link>
		<dc:creator>max</dc:creator>
		<pubDate>Thu, 19 Jan 2012 17:17:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20180</guid>
		<description><![CDATA[@Alexander
i have the code working already. i used it from another guys post in that blog. it has the JS code and all. i put the functions in hear into there, but kept the others. it doesnt work any different? i tried lots of ways like nsloging the function and replacing the x and y with %i and using point.x and point.y, return nothing, and tried more.. i dont get anything from the functions.. can you show me code of how to use these nows? they are all in the JS code. thanks]]></description>
		<content:encoded><![CDATA[<p>@Alexander<br />
i have the code working already. i used it from another guys post in that blog. it has the JS code and all. i put the functions in hear into there, but kept the others. it doesnt work any different? i tried lots of ways like nsloging the function and replacing the x and y with %i and using point.x and point.y, return nothing, and tried more.. i dont get anything from the functions.. can you show me code of how to use these nows? they are all in the JS code. thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20177</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Thu, 19 Jan 2012 15:48:22 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20177</guid>
		<description><![CDATA[@max
Please also read the other blog posts, like http://www.icab.de/blog/2011/08/02/adding-javascript-files-as-resources-to-an-xcode-project/
Here you&#039;ll find out how to include JS code into your Xcode project and how to inject it into the web page.]]></description>
		<content:encoded><![CDATA[<p>@max<br />
Please also read the other blog posts, like <a href="http://www.icab.de/blog/2011/08/02/adding-javascript-files-as-resources-to-an-xcode-project/" rel="nofollow">http://www.icab.de/blog/2011/08/02/adding-javascript-files-as-resources-to-an-xcode-project/</a><br />
Here you&#8217;ll find out how to include JS code into your Xcode project and how to inject it into the web page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: max</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-20173</link>
		<dc:creator>max</dc:creator>
		<pubDate>Thu, 19 Jan 2012 14:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-20173</guid>
		<description><![CDATA[i put all this code in the JSTools.js.. how do i use this new code?:[]]></description>
		<content:encoded><![CDATA[<p>i put all this code in the JSTools.js.. how do i use this new code?:[</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexander</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-16894</link>
		<dc:creator>Alexander</dc:creator>
		<pubDate>Sat, 22 Oct 2011 13:06:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-16894</guid>
		<description><![CDATA[@Shawn
I can&#039;t reproduce this on my devices. But maybe some other settings have to be also configured in a certain way to get this effect. In any case, if you see this strange effect, and you&#039;re sure that this is not your own fault, this is probably a bug and you should report this to Apple.]]></description>
		<content:encoded><![CDATA[<p>@Shawn<br />
I can&#8217;t reproduce this on my devices. But maybe some other settings have to be also configured in a certain way to get this effect. In any case, if you see this strange effect, and you&#8217;re sure that this is not your own fault, this is probably a bug and you should report this to Apple.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shawn</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-16838</link>
		<dc:creator>Shawn</dc:creator>
		<pubDate>Fri, 21 Oct 2011 00:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-16838</guid>
		<description><![CDATA[I have an interesting issue ... When I change my &quot;Region Format&quot; in Settings-&gt;General-&gt;International from &quot;United States&quot; to &quot;Dutch-&gt;Belgium&quot; the elementFromPoint function always returns null. If I switch it back it works perfectly. This happens in all iOS versions that I have been able to test.

Any thoughts?]]></description>
		<content:encoded><![CDATA[<p>I have an interesting issue &#8230; When I change my &#8220;Region Format&#8221; in Settings-&gt;General-&gt;International from &#8220;United States&#8221; to &#8220;Dutch-&gt;Belgium&#8221; the elementFromPoint function always returns null. If I switch it back it works perfectly. This happens in all iOS versions that I have been able to test.</p>
<p>Any thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: NotAnExpert</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-16783</link>
		<dc:creator>NotAnExpert</dc:creator>
		<pubDate>Wed, 19 Oct 2011 15:32:38 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-16783</guid>
		<description><![CDATA[Alexander,

Thank you for sharing your ideas about using UIWebView to create a web browser app for iOS. 

Here&#039;s a function that I use to find an element in a document that contains frames, in case anyone might find it useful. The function makes liberal use of your concepts, for which I am deeply indebted.

&lt;pre&gt;
function MyElementFromPoint(x, y)
{
	/*
		The isUsingViewportCoords variable will be true in the case of iOS 5 or later 
		behavior and the window is scrolled, and will be false if using pre-iOS 5 behavior 
		or the window is not scrolled, even if using iOS 5 or later behavior.
	*/
	var isUsingViewportCoords = true;
	// If scrolled in X direction...
	if (window.pageXOffset &gt; 0) {
		// ...and if an element is found beyond the right edge of the window...
		if (document.elementFromPoint(window.pageXOffset + window.innerWidth - 1, 0)) {
			// ...the operating system is not using viewport coordinates.
			isUsingViewportCoords = false;
		}
	}
	// Else if scrolled in Y direction...
	else if (window.pageYOffset &gt; 0) {
		// ...and if an element is found beyond the lower edge of the window...
		if (document.elementFromPoint(0, window.pageYOffset + window.innerHeight - 1)) {
			// ...the operating system is not using viewport coordinates.
			isUsingViewportCoords = false;
		}
	}
	// If not using viewport coordinates, must first add scroll offsets to get correct 
	// element.
	if (!isUsingViewportCoords) {
		x += window.pageXOffset;
		y += window.pageYOffset;
	}
	// Get element from point in document. Then move down hierarchy of frame and 
	// iframe elements until a non-frame/iframe element is found. That element 
	// is the element at the point x,y in the document.
	var doc = document;
	var elem = doc.elementFromPoint(x, y);
	while (elem.nodeName == &quot;FRAME&quot; &#124;&#124; elem.nodeName == &quot;IFRAME&quot;) {
		// If using viewport coordinates, must account for offset of the frame or 
		// iframe element.
		if (isUsingViewportCoords) {
			var boundRect = elem.getBoundingClientRect();
			x -= boundRect.left;
			y -= boundRect.top;
		}
		doc = elem.contentDocument;
		elem = doc.elementFromPoint(x, y);
	}
	return elem;
}
&lt;/pre&gt;

Caveat: I&#039;m not an IT guy, and certainly not an expert in html, javascript, or any other computer stuff. But the code above is getting it done so far (tested on iOS 4.2, iOS 4.3, and iOS 5). I have developed a limited-feature web browser for accessing a company internal-use web site (about 5000 users). This site uses, shall we say, antiquated web techniques that just don&#039;t work with any of the standard iOS browsers (frames, double-click handlers, command- and shift-keys, eyebrow-raising javascript, etc.).

Alexander, I couldn&#039;t have created this app without your ideas. Again, thank you.]]></description>
		<content:encoded><![CDATA[<p>Alexander,</p>
<p>Thank you for sharing your ideas about using UIWebView to create a web browser app for iOS. </p>
<p>Here&#8217;s a function that I use to find an element in a document that contains frames, in case anyone might find it useful. The function makes liberal use of your concepts, for which I am deeply indebted.</p>
<pre>
function MyElementFromPoint(x, y)
{
	/*
		The isUsingViewportCoords variable will be true in the case of iOS 5 or later 
		behavior and the window is scrolled, and will be false if using pre-iOS 5 behavior 
		or the window is not scrolled, even if using iOS 5 or later behavior.
	*/
	var isUsingViewportCoords = true;
	// If scrolled in X direction...
	if (window.pageXOffset &gt; 0) {
		// ...and if an element is found beyond the right edge of the window...
		if (document.elementFromPoint(window.pageXOffset + window.innerWidth - 1, 0)) {
			// ...the operating system is not using viewport coordinates.
			isUsingViewportCoords = false;
		}
	}
	// Else if scrolled in Y direction...
	else if (window.pageYOffset &gt; 0) {
		// ...and if an element is found beyond the lower edge of the window...
		if (document.elementFromPoint(0, window.pageYOffset + window.innerHeight - 1)) {
			// ...the operating system is not using viewport coordinates.
			isUsingViewportCoords = false;
		}
	}
	// If not using viewport coordinates, must first add scroll offsets to get correct 
	// element.
	if (!isUsingViewportCoords) {
		x += window.pageXOffset;
		y += window.pageYOffset;
	}
	// Get element from point in document. Then move down hierarchy of frame and 
	// iframe elements until a non-frame/iframe element is found. That element 
	// is the element at the point x,y in the document.
	var doc = document;
	var elem = doc.elementFromPoint(x, y);
	while (elem.nodeName == "FRAME" || elem.nodeName == "IFRAME") {
		// If using viewport coordinates, must account for offset of the frame or 
		// iframe element.
		if (isUsingViewportCoords) {
			var boundRect = elem.getBoundingClientRect();
			x -= boundRect.left;
			y -= boundRect.top;
		}
		doc = elem.contentDocument;
		elem = doc.elementFromPoint(x, y);
	}
	return elem;
}
</pre>
<p>Caveat: I&#8217;m not an IT guy, and certainly not an expert in html, javascript, or any other computer stuff. But the code above is getting it done so far (tested on iOS 4.2, iOS 4.3, and iOS 5). I have developed a limited-feature web browser for accessing a company internal-use web site (about 5000 users). This site uses, shall we say, antiquated web techniques that just don&#8217;t work with any of the standard iOS browsers (frames, double-click handlers, command- and shift-keys, eyebrow-raising javascript, etc.).</p>
<p>Alexander, I couldn&#8217;t have created this app without your ideas. Again, thank you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thantthet</title>
		<link>http://www.icab.de/blog/2011/10/17/elementfrompoint-under-ios-5/comment-page-1/#comment-16778</link>
		<dc:creator>thantthet</dc:creator>
		<pubDate>Wed, 19 Oct 2011 13:10:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.icab.de/blog/?p=214#comment-16778</guid>
		<description><![CDATA[Thanks. This solves the problem.]]></description>
		<content:encoded><![CDATA[<p>Thanks. This solves the problem.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
