0

有谁知道下面的代码是否可以工作,我们有 3 个站点可以从一个 IP 地址访问,目前正在使用 2 个,并且它们的脚本可以工作(The Vault & jths.co.uk),但是已经建立了第三个站点所以需要进行更多的重定向.....

想法?

var Redirects = function(currentUrl) {

    var urls = [
    {
        check : 'thevault',
        redirect : 'http://thevault.co.uk/index.phtml?d=512060'
    },

    {
        check : 'jths',
        redirect : 'http://jths.co.uk/index.phtml?d=541300'
    },

    {
        check : 'nationalforestteachingschool',
        redirect : 'http://jths.co.uk/index.phtml?d=550968&preview=1&t=1371981393'
    },
];

    this.init = function() {
        var length = urls.length;

        for ( var i = 0 ; i < length ; i++) {
            var current = urls[i];
            if( currentUrl.indexOf(current.check) > -1) {
                alert("Redirecting to " + current.redirect);
                //window.location = current.redirect
            }
        }
    }
    this.init();
}

var redirects = new Redirects(window.location.href)
4

0 回答 0