代碼功能:每次刷新頁面顯示一個圖片,連接地址和圖片地址內容存放在數組nameAds中。
<script type="text/Javascript">
<!--
//By aloxy,Email/MSN:szyjj@hotmail.com,2005/2
var totalAds = 10;//圖片數量(數組大小)
var nameAds = new Array(totalAds);
var linkAds = new Array(totalAds);
var imgAds = new Array(totalAds);
nameAds[0]="DELL";linkAds[0]="#";imgAds[0]="images/ad/dell.gif";
nameAds[1]="GMTV";linkAds[1]="#";imgAds[1]="images/ad/gmtv.gif";
nameAds[2]="Interflora";linkAds[2]="#";imgAds[2]="images/ad/interflora.gif";
nameAds[3]="Johnson & Johnson";linkAds[3]="#";imgAds[3]="images/ad/jj.gif";
nameAds[4]="MTV";linkAds[4]="#";imgAds[4]="images/ad/mtv.gif";
nameAds[5]="Standard Life";linkAds[5]="#";imgAds[5]="images/ad/standard_life.gif";
nameAds[6]="Toys R Us";linkAds[6]="#";imgAds[6]="images/ad/toysrus.gif";
nameAds[7]="Tui-Thomson";linkAds[7]="#";imgAds[7]="images/ad/tui-thomson.gif";
nameAds[8]="River Island";linkAds[8]="#";imgAds[8]="images/ad/ri.gif";
nameAds[9]="Chrysalis";linkAds[9]="#";imgAds[9]="images/ad/chrysalis.gif";
var numAds = Math.floor(Math.random() * totalAds);
document.write('<a href="'+ linkAds[numAds] +'" target="_blank" class="bodylink"><img src="'+ imgAds[numAds] +'" width="150" alt="'+ nameAds[numAds] +'" border="0"><br>'+ nameAds[numAds] +'</a>');
document.write('<img src="'+ imgAds[numAds] +'" alt="'+ nameAds[numAds] +'" border="0">');
// -->
</script>