Click to See Complete Forum and Search --> : Calling functions from a new window...?


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;
}

zachzach
12-06-2003, 08:57 PM
window.opener.functionname()
window.opener.document
ect

Rowd
12-07-2003, 01:53 AM
Originally posted by zachzach
window.opener.functionname()
window.opener.document
ect

Thankyou, it works. I tried opener before, but used it within the functions themselves and of course it didn't work. I must have just been too tired.

zachzach
12-07-2003, 09:01 AM
welcome.lol.