我有這個應該工作的JavaScript。我沒有看到它的行動,但我希望它能起作用。 JS應該選擇一個隨機圖像,然後顯示屬於該圖片的文本,該圖片也應該作爲另一個頁面的鏈接。旋轉圖片庫,帶有文本和鏈接
但是!我無法讓它工作!有什麼遺漏或缺少如何在我的網站上實現它?
!!腳本更新!
我的JS - 我保持在一個單獨的文件:
<script type="text/javascript">
var imagenumber = 10 ;
var randomnumber = Math.random() ;
var rand1 = Math.round((imagenumber-1) * randomnumber) + 1 ;
images = new Array;
images[1] = "img/rot3gal/cash.jpg";
images[2] = "img/rot3gal/carinjo.jpg";
images[3] = "img/rot3gal/casillas.jpg";
images[4] = "img/rot3gal/churchill.tif";
images[5] = "img/rot3gal/colman.jpg";
images[6] = "img/rot3gal/concosmos.jpg";
images[7] = "img/rot3gal/cooper.jpg";
images[8] = "img/rot3gal/corlando.jpg";
images[9] = "img/rot3gal/magicmemphis.jpg";
images[10] = "img/rot3gal/sidney.jpg";
var image = images[rand1];
links = new Array;
links[1] = "http://www.stutteri-volstrup.dk/cash.shtml";
links[2] = "http://www.stutteri-volstrup.dk/carinjo.shtml";
links[3] = "http://www.stutteri-volstrup.dk/casillas.shtml";
links[4] = "http://www.stutteri-volstrup.dk/churchill.shtml";
links[5] = "http://www.stutteri-volstrup.dk/colman.shtml";
links[6] = "http://www.stutteri-volstrup.dk/concosmos.shtm;l"
links[7] = "http://www.stutteri-volstrup.dk/cooper.shtml";
links[8] = "http://www.stutteri-volstrup.dk/corlando.shtml";
links[9] = "http://www.stutteri-volstrup.dk/magicmemphis.shtml";
links[10] = "http://www.stutteri-volstrup.dk/sidney.shtml";
var link = links[rand1];
var Quotation=new Array() ;
Quotation[1] = "Volstrups Cash";
Quotation[2] = "Carinjo DVH 847";
Quotation[3] = "Volstrups Casillas DVH 928";
Quotation[4] = "Churchill EDH 475";
Quotation[5] = "Colman";
Quotation[6] = "Con Cosmos DVH 898";
Quotation[7] = "Blejsbjergs Cooper DVH 874";
Quotation[8] = "Corlando EDH 476";
Quotation[9] = "Magic Memphis";
Quotation[10] = "Sidney DH 412";
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){ return Quotation[whichQuotation];}
</script>
我用來獲取圖像和鏈接:
<script language="JavaScript" type="text/JavaScript">
document.write('<A HREF="' + link + '"><IMG SRC="' + image + '" alt="' + showQuotation() + '" border="0" width="110" height="90"></a>')
</script>
我用什麼來獲取報價:
<script language="JavaScript" type="text/JavaScript">
showQuotation();
</script>
希望你們能幫助我,所以我可以得到這個腳本工作:)
一個[小提琴](http://jsfiddle.net/)可能有助於解釋 – shyamnathan
試過,但用的jsfiddle錯誤出來的...因此jsfiddle只會顯示這裏顯示的內容...... –
jsfiddle將提供一個測試環境,我們可以使用它來處理。 – kthornbloom