简单JS代码实现打开页面自动打开支付宝客户端领取红包 苹果 安卓 微信 QQ 浏览
简单JS代码实现苹果、安卓、微信、QQ、手机浏览器打开页面自动打开支付宝领取红包
代码如下,其实非常简单主要用到判断浏览器UA功能,并跳转打开浏览器,然后通过浏览器调用支付宝客户端实现领取红包功能
演示:https://www.bnxb.com/demo/other/openzfb.html (跳转方式打开链接)
演示2:https://www.bnxb.com/demo/other/openalipay/ (直接调用支付宝APP)
https://qr.alipay.com/c1x06940rvdipcqw8aoh5e5
这个支付宝领红包链接的来源说明:进入活动页面,然后生成你的分享二维码图片,然后将图片截图,传到https://tool.bnxb.com/qrcode/qrcodescan.html进行解码
演示1的全部代码如下:
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge, chrome=1">
<title>正在打开支付宝,请稍候……</title>
</head>
<body>
<script>
var _0 = "https://qr.alipay.com/c1x06940rvdipcqw8aoh5e5";
var _1 = "https://qr.alipay.com/c1x06940rvdipcqw8aoh5e5";
function is_weixin() {
if (/MicroMessenger/i.test(navigator.userAgent)) {
return true
} else {
return false
}
}
function is_android() {
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/(Android|SymbianOS)/i)) {
return true
} else {
return false
}
}
function is_ios() {
var ua = navigator.userAgent.toLowerCase();
if (/iphone|ipad|ipod/.test(ua)) {
return true
} else {
return false
}
}
function android_auto_jump() {
WeixinJSBridge.invoke("jumpToInstallUrl", {}, function(e) {});
window.close();
WeixinJSBridge.call("closeWindow")
}
function ios_auto_jump() {
if (_0 != "") {
location.href = _0
} else {
window.close();
WeixinJSBridge.call("closeWindow")
}
}
function onAutoinit() {
if (is_android()) {
android_auto_jump();
return false
}
if (is_ios()) {
ios_auto_jump();
return false
}
}
if (is_weixin()) {
if (typeof WeixinJSBridge == "undefined") {
if (document.addEventListener) {
document.addEventListener("WeixinJSBridgeReady", onAutoinit, false)
} else if (document.attachEvent) {
document.attachEvent("WeixinJSBridgeReady", onAutoinit);
document.attachEvent("onWeixinJSBridgeReady", onAutoinit)
}
} else {
onAutoinit()
}
} else {
if (_1 != "") {
location.href = _1
} else {
window.close()
}
}
</script>
</body>
</html>演示2的全部代码如下:
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="Power:AliPay.com">
</head>
<body>
<h6 style="font-size:80px;"><a id="gogo" href="alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=https://qr.alipay.com/c1x06940rvdipcqw8aoh5e5"><!--PS:目前只能苹果QQ,微博,安卓QQ和浏览器还有微博可以使用本跳转功能 -->
</a></h6>
<center>
</div>
</center>
<script src="https://open.mobile.qq.com/sdk/qqapi.js?_bid=152"></script>
<script>
window.onhashchange = function() {
document.getElementById("gogo").click();
};
function hh() {
document.getElementById("gogo").click();
mqq.ui.openUrl({
target: 2,
url: "alipays://platformapi/startapp?saId=10000007&clientVersion=3.7.0.0718&qrcode=https://qr.alipay.com/c1x06940rvdipcqw8aoh5e5"
});
};
setTimeout('hh();', 500);
</script>
</body>
</html>
顶(0)
踩(2)
- 最新评论
