想要打开自己域名网站A,先跳转到非自己网页B,再跳转到最终目的非自己网页C

网站最终的目的页面是C,

想要打开自己域名网站A,先跳转到非自己网页B,再跳转到最终目的非自己网页C。

目前已经实现打开A,自动跳转C了
也可以接受打开A-B-C,也接受A-C-B,也接受B-A-C
想请问这个有办法实现自动跳转吗?

A网站里的iframe设置全屏,其中加载B,显示一定时间后,从A中跳转到C。

你是想在HTML实现还是服务器NGINX实现

用 iframe onload里面加载下一个页面

考虑一下iframe 实现

基本只能用iframe,结合A上面外部页面的定时器之类才能实现。不过效果也就那样。

img

A.界面


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    自己网站A
    <script>
        window.onload = function () {
            console.log('网站A加载完')
            setTimeout(() => {
                let iframe = document.createElement('iframe');
                iframe.src = "./b.html";
                document.body.appendChild(iframe);
            }, 5000)

        }
    </script>
</body>

</html>

b.界面


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    自己网站b
    <script language="javascript" type="text/javascript">
        window.onload = function () {
            console.log('网站b加载完')
            if (window.top != null && window.top.location != window.location) {
                window.top.location = window.location;
            }
            setTimeout(() => {
                let iframe = document.createElement('iframe');
                iframe.src = "./c.html";
                document.body.appendChild(iframe);
            }, 1000)

        }


    </script>
</body>

</html>

c 界面


<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    自己网站c
    <script language="javascript" type="text/javascript">
        window.onload = function () {
            console.log('自己网站c')
            if (window.top != null && window.top.location != window.location) {
                window.top.location = window.location;
            }
        }

    </script>
</body>

</html>

用反向代理
1.访问a没问题,a中访问b也没问题,没啥说的
2.访问b的时候,使用反向代理, proxy_pass https://xxx.xxx.com/b 访问b网站,在返回的内容中,加入script document.location='https://xxx.xxx.com/c' 跳转到c

location /b/ {
  proxy_pass https://xxx.xxx.com/b/;
  proxy_set_header Accept-Encoding "";
    sub_filter </body>  '</body><script>
 document.location='https://xxx.xxx.com/c'
</script> ';
  sub_filter_once off;
  add_header Cache-Control no-cache;
}

iframe?

用Nginx反向代理可以实现

通过控制iframe是完全可以在客户端实现跳转b、c页面的,也可以在服务器以代理的方式访问b、c页面。最为核心的是,这个访问顺序的控制(iframe域服务器代理都可以实现,【iframe方式可以通过监听b页面iframe的onload函数在动态添加c页面的iframe实现】,【服务器代理的话,用curl等方式代理实现,可以获取外域网站的结果(含cookie和页面内容)】);然后是,访问外域网站结果的获取,iframe是无法获取外域网站的内容的。