开发者

Random Images- how to add links?

How do I add开发者_JS百科 link to these sets of random images. I want a link to A B and C respectively and I want these colors to match up. In the page I'm working on (my own personal art site) these colors will be images.

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>


Either, as Rodaine said, you could change your code to be:

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>"

but a better thing to consider is imagemaps.
It seems that you have an image that you've cut up and are now using for different links. If that's the case check out http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_areamap which is a playground for the information here: http://www.w3schools.com/TAGS/tag_map.asp


If you want the whole image to be a link, wrap the <IMG> tags within an anchor:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜