Skip to content

Instantly share code, notes, and snippets.

@por
Forked from kylebarrow/example.html
Created June 23, 2011 09:23

Revisions

  1. @kylebarrow kylebarrow created this gist Jun 23, 2011.
    21 changes: 21 additions & 0 deletions stay_standalone.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    // Mobile Safari in standalone mode
    if(("standalone" in window.navigator) && window.navigator.standalone){

    window.addEventListener("load",function() {

    links = document.getElementsByTagName('a');

    for (var i=0; i < links.length; i++)
    {
    // Don't do this for javascript: links
    if(links[i].href.toLowerCase().indexOf('javascript') !== 0)
    {
    links[i].addEventListener("click",function(event){
    top.location.href = this.href;
    event.returnValue = false;
    },false);
    }
    }
    },false);

    }