sigurs
03-04-2003, 06:14 AM
I am trying to use JavaScript to open a picture (from a picture gallery) in a new window. In addition, I want to install three links in this new window: first one to close the window, second to see the next picture and third to see the previous picture.
To do so, I built a table. In the first row is the "close window" link. In the second is the picture and in the third one are links to previous and next pictures.
Function "show_img" displays the table and its contents, but when I call it (within itself) to see the next (or the previous) picture I get an "Error on page" error.
Here is a piece of my code:
var gallery=new Array ("view1.GIF","view2.GIF", "view3.GIF", "view4.GIF")
var i=0;
var powrot=new String("Go back to the gallery");
var pop=new String("Previous");
var nas=new String("Next");
function show_img(i){
w.document.write('<table align="center">')
w.document.write('<tr valign="top" align="right"><td colspan="2">')
w.document.write('<a href="javascript:close()">'+powrot+'</a></td></tr>')
w.document.write('<tr><td align="center">')
w.document.write('<img src="'+gallery[i]+'"></td></tr>')
if (i==0){
w.document.write('<tr><td valign="bottom" align="right">')
i = i + 1;
//here "show_img" doesn't work
w.document.write('<a href="javascript:show_img(i)">'+nas+'</td></tr></table>')
//here it works
show_img(i);
}
else if (i==galeria.length-1){...}
}
//function "show_img" is called by "display_image"
function display_image(i){
w=window.open("slide_show.htm");
show_img(i);
}
I appreciate your help.
Thank you
To do so, I built a table. In the first row is the "close window" link. In the second is the picture and in the third one are links to previous and next pictures.
Function "show_img" displays the table and its contents, but when I call it (within itself) to see the next (or the previous) picture I get an "Error on page" error.
Here is a piece of my code:
var gallery=new Array ("view1.GIF","view2.GIF", "view3.GIF", "view4.GIF")
var i=0;
var powrot=new String("Go back to the gallery");
var pop=new String("Previous");
var nas=new String("Next");
function show_img(i){
w.document.write('<table align="center">')
w.document.write('<tr valign="top" align="right"><td colspan="2">')
w.document.write('<a href="javascript:close()">'+powrot+'</a></td></tr>')
w.document.write('<tr><td align="center">')
w.document.write('<img src="'+gallery[i]+'"></td></tr>')
if (i==0){
w.document.write('<tr><td valign="bottom" align="right">')
i = i + 1;
//here "show_img" doesn't work
w.document.write('<a href="javascript:show_img(i)">'+nas+'</td></tr></table>')
//here it works
show_img(i);
}
else if (i==galeria.length-1){...}
}
//function "show_img" is called by "display_image"
function display_image(i){
w=window.open("slide_show.htm");
show_img(i);
}
I appreciate your help.
Thank you