Created
September 26, 2012 11:51
-
-
Save Ahrengot/3787592 to your computer and use it in GitHub Desktop.
Prevent iOS web app's from opening internal links in safari
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script> |
p.s. I was just exploring some other options this morning and I'm wondering if there would be a simple way to use the jQuery load method on internal pages to use an ajax load for page content. This way toolbars and such could stay while the page is loaded.
$("#area").load("something.html #area > *");
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is excellent! It's better than the other scripts i've implemented. You seemed to have taken into account anchors with hashtags (which I use for buttons to trigger jQuery events.) but still allows users to click to outbound urls too.
Would you mind adding the code with comments to help explain the logic behind how you designed it?