ton*_*099 20 html javascript jquery android ios
我将以下列格式向我的客户发送应用程序的链接
http://goo.gl.com/downloadtheapp(或其他)
我希望这个文件在我的服务器上的某个地方,包括检查设备类型是什么的java脚本代码,并重定向到方便的商店.也就是说,如果该设备是基于Android的谷歌播放和如果该设备是基于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>
Run Code Online (Sandbox Code Playgroud)
Gov*_*ngh 33
问题出在你的脚本标签上,你就错过了 );
顺便问一下你导入了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>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29698 次 |
| 最近记录: |