I made this small script to avoid having too many if / else statements, basically you define all your checks and redirects in the beginning and then let the script loop through them:
http://jsfiddle.net/XYaFg/1/
var Redirects = function(currentUrl) {
var urls = [
{
check : 'thevault',
redirect : 'http://thevault.co.uk/index.phtml?d=512060'
},
{
check : 'fiddle',
redirect : 'http://another-url-to-redirect-to.html'
},
{
check : 'last-url-check',
redirect : 'http://some-more-redirect.html'
},
];
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)
You have to uncomment the "window.location" row and comment out the "alert" stuff
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…