forked from weblab/sistertalk
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Support for staying in webapp
- Loading branch information
briandunnigan
authored and
briandunnigan
committed
Jan 28, 2016
1 parent
2ea83c5
commit 47bf981
Showing
4 changed files
with
31 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(function(document,navigator,standalone) { | ||
// prevents links from 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; | ||
} | ||
// Conditions to do this only on links to your own app | ||
// if you want all links, 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'); | ||
|
||
|
This file contains 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