Guest User

Untitled

a guest
Mar 20th, 2018
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. (function(document, navigator, standalone) {
  2. // prevents links from apps from oppening in mobile safari
  3. // this javascript must be the first script in your <head>
  4. if ((standalone in navigator) && navigator[standalone]) {
  5. var curnode,
  6. location = document.location,
  7. stop = /^(a|html)$/i;
  8. document.addEventListener('click', function(e) {
  9. curnode = e.target;
  10. while (!(stop).test(curnode.nodeName)) {
  11. curnode = curnode.parentNode;
  12. }
  13. // Condidions to do this only on links to your own app
  14. // if you want all links, use if('href' in curnode) instead.
  15. if ('href' in curnode && (curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host)) && e.defaultPrevented !== true) {
  16. e.preventDefault();
  17. location.href = curnode.href;
  18. }
  19. }, false);
  20. }
  21. })(document, window.navigator, 'standalone');
  22.  
  23. (function(document, navigator, standalone) {
  24. // prevents links from apps from oppening in mobile safari
  25. // this javascript must be the first script in your <head>
  26. if ((standalone in navigator) && navigator[standalone]) {
  27. var curnode,
  28. location = document.location,
  29. stop = /^(a|html)$/i;
  30. document.addEventListener('click', function(e) {
  31. curnode = e.target;
  32. while (!(stop).test(curnode.nodeName)) {
  33. curnode = curnode.parentNode;
  34. }
  35. if (e.target.getAttribute('rel') == 'external') {
  36. window.open("http://www.google.com");
  37. } else {
  38. // Condidions to do this only on links to your own app
  39. // if you want all links, use if('href' in curnode) instead.
  40. if ('href' in curnode && (curnode.href.indexOf('http') || ~curnode.href.indexOf(location.host)) && e.defaultPrevented !== true) {
  41. e.preventDefault();
  42. location.href = curnode.href;
  43. }
  44. }
  45. }, false);
  46. }
  47. })(document, window.navigator, 'standalone');
Add Comment
Please, Sign In to add comment