如何添加这些随机图像集的链接。我想分别链接到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 :(得分: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>"
但最好考虑的是imagemaps 看来你有一个你已经剪掉的图像,现在用于不同的链接。如果是这种情况,请查看http://www.w3schools.com/TAGS/tryit.asp?filename=tryhtml_areamap,其中包含以下信息的操场:http://www.w3schools.com/TAGS/tag_map.asp
答案 1 :(得分:0)
如果您希望整个图像成为链接,请将<IMG>
标记包装在锚点中:
<A HREF='http://link.to/wherever.html'><IMG ...></A>