Rowd
12-06-2003, 06:32 PM
My javascript opens a new window that contains an image and a 'next' button. The next button should replace the original
image with the next image from an array (arrayImg). Problem: the next button does nothing. The functions work when I use them within a single window (not opening a new one) so there's obviously something extra I've left out, but I don't know what. Can anyone help?
var currentID = 0;
arrayImg = new Array();
arrayImg[0] = "brick.jpg";
arrayImg[1] = "gray.jpg";
function displayRemotePhoto(photoID) {
currentID = photoID;
remoteWindow = window.open( "", "remoteWindow" );
remoteWindow.document.write("<img src='' alt='' name='remoteDisplay' id='remoteDisplay'>");
remoteWindow.document.write("<a href='javascript:showNext()'><img src='../Icons/nextButton.gif' name = 'name' id='next'></a>");
remoteWindow.document.remoteDisplay.src = arrayImg[currentID];
remoteWindow.document.close();
}
function showNext() {
getNextID();
remoteWindow.document.remoteDisplay.src = arrayImg[currentID];
}
function getNextID() {
currentID++;
if(currentID >= totalElements) currentID = 0;
}
image with the next image from an array (arrayImg). Problem: the next button does nothing. The functions work when I use them within a single window (not opening a new one) so there's obviously something extra I've left out, but I don't know what. Can anyone help?
var currentID = 0;
arrayImg = new Array();
arrayImg[0] = "brick.jpg";
arrayImg[1] = "gray.jpg";
function displayRemotePhoto(photoID) {
currentID = photoID;
remoteWindow = window.open( "", "remoteWindow" );
remoteWindow.document.write("<img src='' alt='' name='remoteDisplay' id='remoteDisplay'>");
remoteWindow.document.write("<a href='javascript:showNext()'><img src='../Icons/nextButton.gif' name = 'name' id='next'></a>");
remoteWindow.document.remoteDisplay.src = arrayImg[currentID];
remoteWindow.document.close();
}
function showNext() {
getNextID();
remoteWindow.document.remoteDisplay.src = arrayImg[currentID];
}
function getNextID() {
currentID++;
if(currentID >= totalElements) currentID = 0;
}