I'm using the following javascript in my application.html.erb to allow my web app to behave like an iOS app when saved from Safari to the home screen. This script prevents links in the app from opening in Safari:
<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>
It works great and when the app is saved to my home screen, all navigation works as expected except the 'Sign out' button, which errors out:
"The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved."
This does not occur when I access the web app from Safari instead of the home screen, and then I tap the 'Sign out' button—it behaves as expected and signs the user out (destroying the session via the 'delete' method).
Any thoughts what part of the javascript might be causing this error or how I can go about fixing this would be appreciated.