我将按以下格式向我的客户发送应用程序的链接
http://goo.gl.com/downloadtheapp (或其他)
我希望此文件位于我的服务器上的某个位置,其中包含检查设备类型并重定向到便利店的 java 脚本代码。也就是说,如果设备是基于 android 的,则使用 google play;如果设备基于 ios,则使用 appstore。
到现在我都试过了,还是不行。
<html>
<head>
<script type="text/javascript">
$(document).ready(function ()
{
if(navigator.userAgent.toLowerCase().indexOf("android") > -1)
{
window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1)
{
window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
}
}
</javascript>
</head>
<body>
</body>
</html>
最佳答案
问题在于您的脚本标签,您缺少 );
顺便问一下,你是否导入了 jQuery?
<script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script>
$(document).ready(function (){
if(navigator.userAgent.toLowerCase().indexOf("android") > -1){
window.location.href = 'http://play.google.com/store/apps/details?id=com.truecaller&hl=en';
}
if(navigator.userAgent.toLowerCase().indexOf("iphone") > -1){
window.location.href = 'http://itunes.apple.com/lb/app/truecaller-caller-id-number/id448142450?mt=8';
}
});
</script>
关于javascript - 重定向到应用商店或谷歌播放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24464602/