我不确定如何将链接添加到我的图像以使它们在新选项卡中可点击。以下代码自动旋转我的图像并具有允许您选择显示哪个图像的按钮,但我不知道如何为每个图像添加链接以将用户带到新选项卡中的链接。任何帮助将不胜感激。谢谢!
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Image-Text</title>
<SCRIPT type="text/javascript" LANGUAGE="JavaScript">
var num=0;
imgArray = [
['pic1.png','Text for Picture 1'],
['pic2.png','Text for Picture 2'],
['pic3.png','Text for Picture 3'],
['pic4.png','Text for Picture 4']
];
/*
*/
function LimitNumber(value) {
if (value < 0) { value = imgArray.length - 1; }
var value = value % imgArray.length;
return value;
}
function slide(slide_num,Mypic,Mylbl) {
document.getElementById(Mypic).src=imgArray[slide_num][0];
document.getElementById(Mylbl).innerHTML=imgArray[slide_num][1];
}
var timedNum = 0;
function TimedImage() {
timedNum++;
timedNum = LimitNumber(timedNum);
slide(timedNum,'mypic','mylbl');
}
var timedFunc = '';
function InitTimeInterval() {
timedFunc = setInterval("TimedImage()",3000);
}
function DisplaySlides(SNo) {
clearInterval(timedFunc);
slide(SNo,'mypic','mylbl');
}
</SCRIPT>
</head>
<body onLoad="InitTimeInterval()">
<center>
<TR>
<TH>
<button onClick="DisplaySlides(0)">T3K's Game Pick</button>
<button onClick="DisplaySlides(1)">T3K's Hardware Pick</button>
<button onClick="DisplaySlides(2)">MEA's Game Pick</button>
<button onClick="DisplaySlides(3)">MEA's Hardware Pick</button>
</TH>
</TR>
<TABLE border="0"><TR><TD>
<TR>
<TH>
<div class="slide">
<IMG id="mypic" SRC="pic1.png" alt="" BORDER="0" HEIGHT="218" WIDTH="500">
<div id="mylbl" style="font-size:larger;">Text for Picture 1</div>
</div>
</TH>
</TR>
</TABLE>
</body>
</html>
</center>