Created
March 17, 2017 15:15
-
-
Save danichim/59c250b7488a6cedad5185f6356b58e9 to your computer and use it in GitHub Desktop.
Force link open in app
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title></title> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
window.onload = function() { | |
var desktopFallback = "https://youtube.com/watch?v=4KnNVK-udTU", | |
mobileFallback = "https://youtube.com/watch?v=4KnNVK-udTU", | |
app = "vnd.youtube://4KnNVK-udTU"; | |
if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) { | |
window.location = app; | |
window.setTimeout(function() { | |
window.location = mobileFallback; | |
}, 25); | |
} else { | |
window.location = desktopFallback; | |
} | |
function killPopup() { | |
window.removeEventListener('pagehide', killPopup); | |
} | |
window.addEventListener('pagehide', killPopup); | |
}; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment