私はモバイルデバイス上にあることを確認し、アプリのリストとそのアプリストアアドレスでフィードを取得してから、デバイスの種類に応じて、ユーザーを正しいアプリページにリダイレクトします。window.locationを使用してアプリケーションストアにリダイレクトする
var redirecToAppPage = function(device, types) {
var url;
if (device === 'android') {
url = types.android;
} else if (device === 'iphone' || device === 'ipod') {
url = types.apple;
} else if (device === 'ipad') {
url = types.apple;
} else if (device === 'blackberry') {
url = types.phone;
}
if (url) {
window.location = url;
return false;
}
return url;
};
これは機能しません。リダイレクトは決して起こらず、代わりにページの残りのコードを実行します。
私は、window.location
、window.location.href
、window.location.assign(url)
、およびwindow.location.replace(url)
を試しましたが、いずれも動作していません。なぜこれがうまくいかないのでしょうか?
あなたはURLの値を調べましたか? console.log(url)。 – Grommy
はい、URLの値は適切なhttps://itunes.apple.com ...リンクです。私がリンクに直接行くと、リンクがポップアップします。 – MikesBarto2002