核心:

var host = window.location.host.toLowerCase();
var url = new Array();
var url2 = "";

url.push("baidu1.com");
url.push("baidu12.com");
url.push("baidu13.com");
url.push("baidu14.com");
url.push("baidu15.com");
url.push("baidu16.com");
url.push("baidu17.com");


//url2 = "http://" + escape(url[Math.floor(Math.random() * url.length)]);
//setTimeout('location.href=url2',5000);
for (var i = 0; i < url.length; i++) {
    if (host.indexOf(url[i]) >= 0) {
        istiao = "0"
    }
}
if (istiao == "1") {
    top.location.href = url2
}

调用:

<script>document.write(escape(url[Math.floor(Math.random() * url.length)]));</script>

方法二,也是利用JS的数组实现.

<script language="javascript" type="text/javascript">
    var arr = new Array(
        "https://www.baidu.com/",
        "http://www.github.com/",
        "https://www.taobao.com/",
    );

    window.location.href = arr[Math.floor(Math.random() * arr.length)];
</script>