<!-- test.html -->
<!doctype html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8" />
<title>test</title>
</head>
<body id="body">
<h2 id="demo"></h2>
</body>
<script>
var body = document.getElementById("demo");
if (location.href.indexOf("jump") != -1) {
body.innerHTML = "A: 主页面\n预期从这个页面自动跳转到B页面";
setTimeout(() => {
location.href = "/test.html";
}, 2000);
} else {
body.innerHTML = "B: 二级页面\n预期点击返回,回到A页面";
}
</script>
</html>
- 把代码写入 test.html
- 用 static-server 等工具启动http服务
- 打开 http://localhost:3000/test.html?jump=1
- 预期会从A页面自动跳转B页面,B页面点击返回能返回A页面
实际:iOS符合预期,安卓直接关闭了webview