Open social media links in their respective applications using js

  javascript, jquery, operating-system, python, web

I want to take users from my page directly to social media apps like Instagram, Facebook, Twitter etc. And I would like to know if this can be achieved using JasvaScript. For an example

<!DOCTYPE html>
        <meta charset="utf-8">
        <script type="text/javascript">
            window.onload = function() {

                var desktopFallback = "",
                mobileFallback = "",
                app = "";

                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);


This code which I found here opens up that respective video in YouTube app according to the device. And here link is being used for opening in the app.

My question is, is there any similar setup available for other apps which I metioned above?

Or how can I achieve similar output for other apps using js or other languages? My focus is to get similar output for Instagram, Facebook, Twitter. For YouTube the above js snippet is being used.

Thanks for your help 🙂

Source: Python Questions