2011-07-01 85 views
0

如何添加鏈接到這些隨機圖像集。我想分別鏈接到A B和C,我希望這些顏色相匹配。在我正在處理的頁面(我自己的個人藝術網站)中,這些顏色將是圖像。隨機圖像 - 如何添加鏈接?

http://rollinleonard.com/please-help/

<!DOCTYPE html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<title>Rollin Leonard</title> 
</head> 
<body> 
<SCRIPT LANGUAGE="Javascript"> 
function banner() { } ; b = new banner() ; n = 0 
b[n++]= "<IMG name=randimg SRC='http://rollinleonard.com/please-help/images/green_01.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/green_02.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/green_03.gif' border='0' ALT=''>" 
b[n++]= "<IMG name=randimg SRC='http://rollinleonard.com/please-help/images/purple_01.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/purple_02.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/purple_03.gif' border='0' ALT=''>" 
b[n++]= "<IMG name=randimg SRC='http://rollinleonard.com/please-help/images/yellow_01.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/yellow_02.gif' border='0' ALT=''><IMG name=randimg SRC='http://rollinleonard.com/please-help/images/yellow_03.gif' border='0' ALT=''>" 
i=Math.floor(Math.random() * n) ; 
document.write(b[i]) 
</SCRIPT> 
</body> 
</html> 

回答

0

如果你想整個形象是一個鏈接,包裹錨內<IMG>標籤:

<A HREF='http://link.to/wherever.html'><IMG ...></A> 
2

無論是作爲Rodaine說,你可以更改您的代碼是:

b[n++]= "<a href='http://url.com'><IMG SRC='green_01.gif'></a><a href='http://url2.com'><IMG SRC='green_02.gif'></a><a href='http://url3.com'><IMG SRC='green_03.gif'></a>" 

但一個更好的事情要考慮的是形象地圖。
看起來你有一張你已經剪下來的圖片,現在用於不同的鏈接。如果是這種情況,請檢查http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_areamap這是一個遊樂場的信息在這裏:http://www.w3schools.com/TAGS/tag_map.asp

+0

太棒了!這太酷了。我想我不需要這個應用程序,但我肯定會玩這個。謝謝你的提示。 – Rollin