通过android浏览器中的javascript重定向打开应用程序的google play details页面
如果我的网站是在android设备上打开的,我希望我的网站能够重定向到Google Play Market中的特定应用程序。我遵照以下指示:通过android浏览器中的javascript重定向打开应用程序的google play details页面,javascript,android,redirect,google-play,Javascript,Android,Redirect,Google Play,如果我的网站是在android设备上打开的,我希望我的网站能够重定向到Google Play Market中的特定应用程序。我遵照以下指示: “显示特定应用程序的详细信息屏幕:http://play.google.com/store/apps/details?id=". 使用用户积极点击的链接效果非常好: <a href="http://play.google.com/store/apps/details?id=<package_name>">Download app&
“显示特定应用程序的详细信息屏幕:http://play.google.com/store/apps/details?id=".
使用用户积极点击的链接效果非常好:
<a href="http://play.google.com/store/apps/details?id=<package_name>">Download app</a>
但如果我用javascript检测设备并尝试重定向浏览器,则会自动更改http://... 到https://... 用户被重定向到Google Play网站,而不是手机上的Google Play应用程序
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location.href= "http://play.google.com/store/apps/details?id=<package_name>";
}
}
if(navigator.userAgent.toLowerCase().indexOf(“android”)>-1){
如果(确认(“下载应用程序?”){
window.location.href=”http://play.google.com/store/apps/details?id=";
}
}
有没有办法改变这种行为,我的测试设备是三星Galaxy和安卓2.3.3 这似乎有效。重定向会在使用默认浏览器时打开Google Play应用程序,但会将链接转换为https://Play.Google。。。当使用铬时
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location.href= "market://details?id=<packagename>";
}
}
if(navigator.userAgent.toLowerCase().indexOf(“android”)>-1){
如果(确认(“下载应用程序?”){
window.location.href=”market://details?id=";
}
}
如果接受的答案不起作用或无法在Chrome中打开并出现此错误
错误:错误\u未知\u URL\u方案
将window.location.href更改为window.location,如下所示
if(navigator.userAgent.toLowerCase().indexOf("android") > -1) {
if(confirm("Download app?")) {
window.location= "market://details?id=<packagename>";
}
}
if(navigator.userAgent.toLowerCase().indexOf(“android”)>-1){
如果(确认(“下载应用程序?”){
window.location=”market://details?id=";
}
}
如果您想重定向到Google Play app,请尝试从服务器上执行
客户端尝试将不起作用
PHP示例
header("Location: market://details?id=com.your.app");
修改链接的href怎么样(
我试图用jquery在链接上触发一个点击事件,但没有成功。你说的“修改链接的href”是什么意思?链接本身正在工作,是javascript重定向导致android浏览器将http://替换为https://Just 想知道,你使用的是默认浏览器还是google chrome beta?我将你的javascript代码片段添加到了一个测试页面中-在我的Galaxy Nexus 4.0.2上使用默认浏览器,它可以像你所期望的那样工作我没有得到“使用完整操作”选项,它只是带我到网站——仍在查看它
header("Location: market://details?id=com.your.app");