有谁知道以下代码是否有效,我们有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)