【问题标题】:Common link to redirect to PlayStore or AppStore accordingly using nodejs使用 nodejs 相应地重定向到 PlayStore 或 AppStore 的通用链接
【发布时间】:2017-12-10 04:30:31
【问题描述】:

我需要根据操作系统创建一个重定向到 Android PlayStore 或 Apple App Store 的通用链接。此链接将在浏览器中打开。

【问题讨论】:

    标签: android ios node.js hyperlink


    【解决方案1】:

    您可以使用 javascript 来做到这一点:

    function changeLink(){
        document.getElementById('link').href= getMobileOperatingSystem();
    }
    
    function getMobileOperatingSystem() {
      var userAgent = navigator.userAgent || navigator.vendor || window.opera;
    
          // Windows Phone must come first because its UA also contains "Android"
        if (/windows phone/i.test(userAgent)) {
            return "windows-link";
        }
    
        if (/android/i.test(userAgent)) {
            return "android-link";
        }
    
        // iOS detection from: http://stackoverflow.com/a/9039885/177710
        if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {
            return "ios-link";
        }
    
        return "ios-link"; // default
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-09-18
      • 2020-05-01
      • 2017-03-07
      • 2018-04-15
      • 1970-01-01
      • 2016-07-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多