Try it yourself
Your generated code:
Copy paste the code, make a new .html file and upload this file to a public hosting service.
Then simply use the file link as your YouTube link and mobile users will always open the YouTube app!
How does it work?
In case the code generator didn't work, or you are just curious, see example below! 😊
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <script type="text/javascript"> window.onload = function() { // fallback link in case user doesn't have the app or opens link on desktop var fallback = "link here", // app to direct to youtube application, last part of link can be; // video: watch?v=your_id // channel: channel/your_id app = "vnd.youtube://last part of link here"; if( /Android|iPhone|iPad|iPod/i.test(navigator.userAgent) ) { window.location = app; window.setTimeout(function() { // couldn't open app, open fallback url window.location = fallback; }, 25); } else { // open url because device doesn't support youtube app window.location = fallback; } function killPopup() { window.removeEventListener('pagehide', killPopup); } window.addEventListener('pagehide', killPopup); }; </script> </body> </html>
It's very simple, all you must do is adding your original link in the fallback variable and adding the last part of your video or channel after youtube.com/ in the app variable.
Create a new .html file and upload it to any public hosting service. This can be your personal website, but you can also use something as dropbox to upload your web file.
Put the link in your bio or link tree and all users will now redirect to the YouTube app instead of opening YouTube in the in app browser.
If you have any questions, feel free to ask in the comments below or send me a direct message on Instagram.
Happy coding! 👨💻
Boy
Many news websites can learn from this!