我需要根据操作系统创建一个重定向到 Android PlayStore 或 Apple App Store 的通用链接。此链接将在浏览器中打开。
最佳答案
您可以使用 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
}
关于android - 使用 nodejs 相应地重定向到 PlayStore 或 AppStore 的公共(public)链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44944279/