吢涼ㄋ
2018-02-07 11:22:14
java服务端返回关闭当前支付宝/微信h5窗口
String userAgent = request.getHeader("user-agent").toLowerCase();
PrintWriter writer = response.getWriter();
StringBuilder sb = new StringBuilder();
//微信客户端
if(userAgent.indexOf("micromessenger") != -1){
sb.append("<html>");
sb.append("<script type='text/javascript' src='https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js'></script>");
sb.append("<script type='text/javascript' src='https://res.wx.qq.com/open/js/jweixin-1.2.0.js'></script>");
sb.append("<script>");
sb.append("if(typeof window.WeixinJSBridge=='undefined'){$(document).on('WeixinJSBridgeReady',function(){WeixinJSBridge.call('closeWindow')})}");
sb.append("</script>");
sb.append("</html>");
}
//支付宝
else if(userAgent.indexOf("alipay") != -1){
sb.append("<html>");
sb.append("<script type='text/javascript' src='https://cdn.bootcss.com/jquery/1.9.1/jquery.min.js'></script>");
sb.append("<script type='text/javascript' src='https://a.alipayobjects.com/g/h5-lib/alipayjsapi/3.0.6/alipayjsapi.min.js'></script>");
sb.append("<script>");
sb.append("if(typeof window.AlipayJSBridge=='undefined'){$(document).on('AlipayJSBridgeReady',function(){AlipayJSBridge.call('closeWebview')})}");
sb.append("</script>");
sb.append("</html>");
}
writer.write(sb.toString());
评论
最近浏览
lamaga LV2
2022年8月25日
123暖壶别炸 LV7
2020年9月2日
fuzuinet LV1
2020年4月2日
hhuangh LV5
2019年11月21日
youwuzuichen LV11
2019年10月4日
陈石养 LV2
2019年7月18日
liyang155 LV1
2019年7月4日
15676663785 LV9
2019年6月12日
jien007 LV11
2019年1月4日
DEVIL_HJM LV4
2018年11月16日





