Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Deeplink Youtube
<!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>
@click2jit

This comment has been minimized.

Copy link

@click2jit click2jit commented Jan 18, 2019

Thank You..

@sajornad

This comment has been minimized.

Copy link

@sajornad sajornad commented May 9, 2019

Best help!

Thanks

@lumyjuwon

This comment has been minimized.

Copy link

@lumyjuwon lumyjuwon commented Sep 16, 2019

Oh my god .. Thank you ..

@sanjeev28

This comment has been minimized.

Copy link

@sanjeev28 sanjeev28 commented Jan 16, 2020

Well Done bro! Very Nice job. Buddy can you share a code to check browser in the phone and open the link in that app.Similar to this code but at the place of youtube it could be a browser and the place of channel link,it could be a website url.

@mubaid

This comment has been minimized.

Copy link

@mubaid mubaid commented May 7, 2020

Doesnt seem to be working anymore? Just tried on Android Chrome/Brave/Firefox.. It opens the YT video in the browser itself.

@Mohammed-Nasser

This comment has been minimized.

Copy link

@Mohammed-Nasser Mohammed-Nasser commented Oct 27, 2020

Thank You.. it working

@YasserTamer

This comment has been minimized.

Copy link

@YasserTamer YasserTamer commented Nov 21, 2020

It works fine with me as well. But when I share it, it appear as coming from my domain. While people using professional deep linking portal the link appear as being from youtube with the same Thumbnail. I wonder if the code can be modified so the shared post looks the same

@benjaminwtwall

This comment has been minimized.

Copy link

@benjaminwtwall benjaminwtwall commented Mar 7, 2021

Looking for a way to deeplink YT for free, found this. So does this need to be hosted on a domain and then will take the viewer straight to the app?

@bassel999

This comment has been minimized.

Copy link

@bassel999 bassel999 commented Apr 3, 2021

The code is working great
But only on chrome browser on Android it will not work.
Any advice?

@M7ammad-eb

This comment has been minimized.

Copy link

@M7ammad-eb M7ammad-eb commented Jun 21, 2021

This is great, thanks.
I've been using it for a while, it worked perfectly, now it's working except on Facebook, it doesn't even fallback to the webpage, just loads white blank page! Any ideas?

@viwicodes

This comment has been minimized.

Copy link

@viwicodes viwicodes commented Sep 18, 2021

Can we do something like this for other apps? Like Instagram, Facebook, Twitter etc?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment