我想在用户在他们的移动浏览器中输入某个URL时将他们重定向到我的Play Store应用程序页面。我尝试了以下代码,但它将重定向到Play Store网站而不是Android手机上的Play Store应用程序。
经过在 Google 上的一些搜索,我发现我必须使用市场 URL。然后我按照以下方式更改了代码。但仍然没有运气。这段代码不会重定向到任何地方。
“有人能帮我确定我在这个问题中错过了什么吗?”
<script type="text/javascript">
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location = "http://play.google.com/store/apps/details?id=com.example";
}
</script>
经过在 Google 上的一些搜索,我发现我必须使用市场 URL。然后我按照以下方式更改了代码。但仍然没有运气。这段代码不会重定向到任何地方。
<script type="text/javascript">
var userAgent = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(userAgent)) {
window.location = "market://details?id=com.example";
}
</script>
“有人能帮我确定我在这个问题中错过了什么吗?”