在微信中引导用户使用浏览器打开页面

我们需要在微信浏览器内的网页中使用支付宝付款时,往往会被微信拦截,

提示:如需浏览,请长按网址复制后使用浏览器访问

分享一个支付宝官方的文档,引导提示微信用户到系统的浏览器打开,然后再进行下一步的流程。

文件:

1.ap.js

网址链接处理脚本

2.go.htm

提示用户打开外部系统浏览器的页面

3.index.html

网站调用的页面,需要在默认系统浏览器打开的地址在此页面填入

自行传入:go.htm?goto=

需要做urlEncode

<html>
<head>
    <meta charset="utf-8"/>
    <title>浏览器打开的地址</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name='apple-touch-fullscreen' content='yes'>
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta name="format-detection" content="address=no">
</head>
<body id="order-check" data-com="pagecommon">
<header class="navbar">
    <h1 class="nav-header">浏览器打开的地址</h1>
</header>
<div class="wrapper-list">
    <h4>浏览器打开的地址</h4>
    <div id="pay-methods-panel" class="pay-methods-panel">
        <div class="wrapper buy-wrapper">
			<!-- 该链接是拼接的请求,需要做urlEncode -->
		    <a href="https://www.77nn.net" class="J-btn-submit btn mj-submit btn-strong btn-larger btn-block">确认</a> 
        </div>
    </div>
</div>
<script type="text/javascript" src="ap.js"></script>
<script>
var btn = document.querySelector(".J-btn-submit");
btn.addEventListener("click", function (e) {
    e.preventDefault();
    e.stopPropagation();
    e.stopImmediatePropagation();
    //ele.href 是GET到新窗口的URL
    _AP.pay(e.target.href);
    return false;
}, false);
</script>
</body>
</html>

ios和安卓提示截图:

图片[1] | 在微信中引导用户使用浏览器打开页面 | 讯沃blog

© 版权声明
THE END
喜欢就支持一下吧
点赞6赞赏 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容