我有一个非常简单的Javascript,用于将特定的URL重定向到Google-Play-Store/iOS-Store中的应用程序,或者根据客户端的操作系统显示桌面用户的URL。对于ios的情况,重定向没有被执行,有人能解释问题是什么吗?(在正确执行重定向之前发出警报!)
var playStoreUrl = "https://play.google.com/store/apps/details?id=xyz",
appStoreUrl = "https://itunes.apple.com/de/app/gxyz/id123456789?mt=8",
desktopUrl = "http://www.xyz.de/apps/";
var isMobile = {
Android: function() {
return navigator.userAgent.match(/Android/i);
},
iOS: function() {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
}
};
if ( isMobile.Android() ) {
alert('os: android!');
window.location.href = playStoreUrl;
}
else if(isMobile.iOS()) {
alert('os: ios!');
window.location.href = appStoreUrl;
}
else {
alert('os: desktop!');
window.location.href = desktopUrl;
}发布于 2015-06-16 11:02:38
解决方案:不要在iOS-Appstore-Link中使用"?mt=8“参数,重定向将有效(并在设备上打开Appstore-App )。
https://stackoverflow.com/questions/30846126
复制相似问题