ratchet
ratchet copied to clipboard
Links open in new browser when it is added to the home screen
I am using iOS6, after adding the ratchet template to the home screen and clicking the links in it, the links open in a new safari browser. Any method to make it to load on the same page?
do you import ratchet.js
?
I now try to do it with http://jakiestfu.github.io/Snap.js/demo/apps/ratchet/template.html Still the same problem. Looking at the source code, it should have imported ratchet.js.
Same problem here when using push.js on iOS7.
Same problem for me. It only happens when you click very fast on 2 or more links. Android (Chrome) works fine.
Same problem for me.
Same. It seems to only happen sporadically. Any thoughts on where to look for a bug — either on my own codebase or on ratchet's?
I think you should search on ratchets codebase (espacially page.js)
It only happens on iOS. Android works fine.
This will solve it 100% for iOS (Tested with iOS 8)
<head>
<title>Stay Standalone!</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="white">
<meta name="apple-mobile-web-app-title" content="Web App title to override title element name">
<!-- With credit to Irae Carvalho - https://gist.github.com/kylebarrow/1042026#comment-37145 -->
<script type="text/javascript">
(function(document,navigator,standalone) {
// Prevents links in apps from oppening in mobile Safari
// This javascript must be the first script in your <head>
if ((standalone in navigator) && navigator[standalone]) {
var curnode, location=document.location, stop=/^(a|html)$/i;
document.addEventListener('click', function(e) {
curnode=e.target;
while (!(stop).test(curnode.nodeName)) {
curnode=curnode.parentNode;
}
// If you want this to affect all links and not just your app, use if('href' in curnode) instead.
if('href' in curnode && ( curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host) ) ) {
e.preventDefault();
location.href = curnode.href;
}
},false);
}
})(document,window.navigator,'standalone');
</script>
</head>
Thanks for the fix, will try it out these days.
@JayHoltslander Doesn't seem to solve it for me.
@JayHoltslander worked! Thanks!
Oh forgot to say that it also worked for me
It works, thanks!