Skip to content

Instantly share code, notes, and snippets.

@NejcZdovc
Created December 22, 2015 07:46
Show Gist options
  • Save NejcZdovc/fb969d01534875eecd8d to your computer and use it in GitHub Desktop.
Save NejcZdovc/fb969d01534875eecd8d to your computer and use it in GitHub Desktop.
IOS native app
/**
* IOS native app
* <meta name="apple-mobile-web-app-capable" content="yes">
*/
(function(document,navigator,standalone) {
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
if('href' in curnode && ( curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host) ) ) {
e.preventDefault();
location.href = curnode.href;
}
},false);
}
})(document,window.navigator,'standalone');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment