Skip to content

Instantly share code, notes, and snippets.

@ogero
Created October 17, 2016 23:25
Show Gist options
  • Save ogero/32c5ab65fa1c7ea44dfd35763a2de443 to your computer and use it in GitHub Desktop.
Save ogero/32c5ab65fa1c7ea44dfd35763a2de443 to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<style>
a.launch{
display: block;
text-align: center;
}
</style>
</head>
<body>
<script>
var LINK_TEXT='Lanzar App';
var APPLINK='labandatransporte://';
var STORELINK='market://details?id=app.labandatransporte';
window.linkAdded=false;
var fallbackFunction = function() {
if(window.linkAdded==false){
window.linkAdded=true;
var a = document.createElement("a");
var aText = document.createTextNode(LINK_TEXT);
a.appendChild(aText);
a.className="launch";
a.href="#";
a.onclick=function(){
return doMagic();
};
document.body.appendChild(a);
}
window.location.replace(STORELINK);
};
var addIFrame = function() {
var iframe = document.createElement("iframe");
iframe.style.border = "none";
iframe.style.width = "1px";
iframe.style.height = "1px";
iframe.src = APPLINK;
document.body.appendChild(iframe);
};
var doMagic = function(){
addIFrame();
setTimeout(fallbackFunction, 1000);
return false;
}
doMagic();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment