我将以以下格式向我的客户发送应用程序的链接
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>发布于 2014-06-28 16:38:46
问题出在您的脚本标记上,您缺少);
顺便问一下,您是否导入了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>https://stackoverflow.com/questions/24464602
复制相似问题