Zwake
09-14-2011, 07:04 PM
So when the page loads the thumbnails cycle through using setInterval. When the user clicks on one of the thumbnails, it is supposed to open a new window and show the enlarged version of that thumbnail stored in bigpics. However it only comes up with a broken image link. Any ideas why this is not working? Here is the code:
<html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript" type="text/javascript">
<!--
var pics = new Array()
pics[0]="pict1.gif"
pics[1]="pict2.gif"
pics[2]="pict3.gif"
pics[3]="pict4.gif"
pics[4]="pict5.gif"
pics[5]="pict6.gif"
var bigpics = new Array()
bigpics[0]="pict12.gif"
bigpics[1]="pict22.gif"
bigpics[2]="pict32.gif"
bigpics[3]="pict42.gif"
bigpics[4]="pict52.gif"
bigpics[5]="pict62.gif"
i=0
setInterval("slide()",500)
function slide(){
if (i<pics.length)
i++
if (i==pics.length)
i=0
document.images[0].src=pics[i]
}
function enlarge(x){
w=window.open()
x=bigpics[i]
w.document.write("<img src='x'>")
}
//-->
</script>
<body>
<img src="pict1.gif" alt="" onclick="enlarge(this)">
</body>
</html>
<html>
<head>
<title>Untitled</title>
</head>
<script language="JavaScript" type="text/javascript">
<!--
var pics = new Array()
pics[0]="pict1.gif"
pics[1]="pict2.gif"
pics[2]="pict3.gif"
pics[3]="pict4.gif"
pics[4]="pict5.gif"
pics[5]="pict6.gif"
var bigpics = new Array()
bigpics[0]="pict12.gif"
bigpics[1]="pict22.gif"
bigpics[2]="pict32.gif"
bigpics[3]="pict42.gif"
bigpics[4]="pict52.gif"
bigpics[5]="pict62.gif"
i=0
setInterval("slide()",500)
function slide(){
if (i<pics.length)
i++
if (i==pics.length)
i=0
document.images[0].src=pics[i]
}
function enlarge(x){
w=window.open()
x=bigpics[i]
w.document.write("<img src='x'>")
}
//-->
</script>
<body>
<img src="pict1.gif" alt="" onclick="enlarge(this)">
</body>
</html>