I am working on a site of a touroperator. For each hotel I am making a page with the hotel information and a number of thumbs. When you click on an image, a new window with the right size opens.
I make the links like this
<A HREF="javascript:openImage('somehotel.gif');"><IMG SRC='somehotel.gif'></A>
and I have this function
function openImage(imgFile, title) {
var img = new Image();
img.src = imgFile;
// alert(img.height);
var imageWindow = open('', '', 'height=' + (img.height + 20) + ', width=' + (img.width+20));
imageWindow.document.open();
imageWindow.document.write("<HTML>\n<HEAD>\n<TITLE>/" + title + "</TITLE></HEAD>\n<BODY BGCOLOR=\"#FEFEEA\" ");
imageWindow.document.write("LEFTMARGIN=10 TOPMARGIN=10 RIGHTMARGIN=10 BOTTOMMARGIN=10>\n ");
imageWindow.document.write("<IMG SRC=\"" + imgFile + "\">\n</BODY>\n</HTML>");
imageWindow.document.close();
img.src = "";
delete img;
}
When I click the first image, it works fine: a window pops up with exactly the right size and the image in it.
But when I click the image again, or another one, without reloading the page, I get a window that is much to small and always of the same size.
The strangest thing is, that if I uncomment the line in red, the function works as it should, even with the second, third, ... image.
Please help me out here, because I don't know what I do wrong!