嗨我一直在试图弄清楚如何使用随机报价脚本,其中每个报价是它的超链接去不同的页面。到目前为止,这是我用于引用的示例。有没有办法让每个引用自己的超链接?随机引用超链接脚本?
<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