故障情况:
test.html 中有 ifname src='weapp.html',weapp.html中跳转到 含有 wx-open-launch-weapp 目标页,在ios 中正常,在安桌中不显示 wx-open-launch-weapp按钮
排查结果:
只要 weapp.html 中含有 window.history.pushState(null, null, "#"); 就不正常;这个现象在旧版的微信中是没有,新版微信才有这个 bug
复现链接:
https://tchf.2qmall.com/addons/bt_tme/test/test.html
test.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试</title>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
</head>
<body>
<div id="bt_iframe_Div" style="position: fixed;height: 100%;width: 100%;top: 100px;left: 0;right: 0; z-index: 0; margin-top: 20px;">
<iframe src="weapp.html" id="bt_frame" width="100%" frameborder="0" style="height: 100%;"></iframe>
</div>
</body>
</html>
weapp.html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试</title>
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, width=device-width">
</head>
<body style="background-color: #dbdbe8;">
<div style=" margin-top: 55px;" onclick="IfameJump();">
点我跳转到小程序(IOS 中正常,android 不显示)
</div>
</body>
<script>
window.history.pushState(null, null, "#");
function IfameJump(){
top.location='https://tchf.2qmall.com/app/index.php?i=1&c=entry&do=jm&m=bt_tme&lgt=wx&pt=mt&poi=bXqu2LklE7TYB7BNtFlYdAI&utm_medium=androidweb&sname=%E5%B0%8F%E7%BA%A2%E4%B9%A6%E7%BE%8E%E9%A3%9F%E5%BA%97%EF%BC%88%E5%B9%BF%E5%B7%9E%E5%BA%97%EF%BC%89'
}
</script>
</html>