<script language=javascript>
i = parseInt(Math.random()*2)
switch(i) {
case 0:location.href='http://www.baidu.com';break;
case 1:location.href='http://www.google.com';break;
}
</script>javascript
<%
file=server.mappath("url.txt") '網址列表路徑
set fs=server.createobject("scripting.filesystemobject") 'fso讀寫組件
set txt=fs.opentextfile(file,1,true) '打開
if not txt.atendofstream then p=split(txt.readall, vbcrlf) '分割爲數組java
randomize '純隨機,不重複
response.redirect p(int((ubound(p) * rnd) + 1)-1) '在(1-數組最大上標)之間生成隨機數,並跳轉到該頁
response.end '結束
%>數組