嗨我一直在試圖弄清楚如何使用隨機報價腳本,其中每個報價是它的超鏈接去不同的頁面。到目前爲止,這是我用於引用的示例。有沒有辦法讓每個引用自己的超鏈接?隨機引用超鏈接腳本?
<script language="JavaScript">
var Quotation=new Array() // do not change this!
Quotation[0] = "Test.";
Quotation[1] = "Sanity is a golden apple with no shoelaces.";
Quotation[2] = "Repent! The end is coming, $9.95 at Amazon.";
Quotation[3] = "Honesty blurts where deception sneezes.";
Quotation[4] = "Pastry satisfies where art is unavailable.";
Quotation[5] = "Delete not, lest you, too, be deleted.";
Quotation[6] = "O! Youth! What a pain in the backside.";
Quotation[7] = "Wishes are like goldfish with propellors.";
Quotation[8] = "Love the river's \"beauty\", but live on a hill.";
Quotation[9] = "Invention is the mother of too many useless toys.";
var Q = Quotation.length;
var whichQuotation=Math.round(Math.random()*(Q-1));
function showQuotation(){document.write(Quotation[whichQuotation]);}
showQuotation();
</script>
你如何確定要去哪個頁面? –
是的。用JavaScript創建HTML或DOM元素。這是JS的典型用途之一,你應該能夠在網上找到大量的例子。例如:http://stackoverflow.com/questions/8005694/make-hyperlink-from-javascript –
我不知道這個例子來自哪裏,但它是從同學那裏得到的,我在學校。 – user1450117