<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Show URL</title>
    <script>
        /*<![CDATA[*/
        // demo 默认值(可独立预览), 服务端渲染时被下一行覆盖
        var navigationConfig = {
            targetUrl: "https://demo.com",
            navSelectionAlgorithm: "d",
            children: []
        };
        navigationConfig = {"navOutStyle":"h301","navPageTemplate":null,"navTemplateCode":null,"targetUrl":"https:\/\/h5.www520kj.com","downloadUrl":null,"refUrlList":[],"navDelaySeconds":1,"id":null,"hostDomain":"520kj.com","hostPort":null,"isHttps":"y","navSelectionAlgorithm":"d","orderNum":null,"parentId":null,"parentHostDomain":null,"status":"y","annotation":null,"page":null,"size":null,"hasParent":false,"hasChildren":false,"children":null,"appDownLoadUrl":"https:\/\/tk6app.com","androidVersion":"V1.4.6","androidUrl":"https:\/\/pw-app-hk.s3.ap-east-1.amazonaws.com\/AndroidBundle\/6tk_prd.apk","iosVersion":"V1.3.1","iosUrl":"https:\/\/tk6app.com\/iosGuide","iosStableVersion":"V1.2.6","iosStableUrl":"https:\/\/tk6app.com\/iosGuide","appName":"6\u56FE\u5E93","navName":"6\u56FE\u5E93","navUrl":"https:\/\/h5.www66853.com","navDisplayUrl":"66853.com"};
        // demo end

        // 决定最终跳转地址:
        //   算法=随机(r) 且有下一节点域名池(children) -> 随机挑一条
        //   否则 -> 跳自己的 targetUrl
        // 一律"对方给什么就跳什么", 不拼协议/端口
        function resolveTarget() {
            var algo = navigationConfig && navigationConfig.navSelectionAlgorithm;
            var list = (navigationConfig && navigationConfig.children) || [];
            if (algo === "r" && list.length) {
                var child = list[Math.floor(Math.random() * list.length)];
                var dest = child && (child.targetUrl || child.hostDomain);
                if (dest) return dest;
            }
            return navigationConfig ? navigationConfig.targetUrl : "";
        }

        function redirectToUrl() {
            var url = resolveTarget();
            if (url) {
                var targetUrl = /^https?:\/\//i.test(url) ? url : "https://" + url;
                window.location.href = targetUrl;
            }
        }

        window.onload = redirectToUrl;
        /*]]>*/
    </script>
</head>

<body>
</body>

</html>