dimamo1983
09-10-2003, 09:33 PM
I would like to display a picture in a new window each time a thumb is clicked. Pretty standard thing to do. I have one catch though. I would like to have a function that automatically determines the size of the window so all I need to pass to it is the location of the picture file. No sizes, nothing else.
I found the scipt on javascriptsource that shows how to do it:
...
var pic = new Image();
pic.src = (url);
var windowWidth = pic.width + 20;
var windowHeight = pic.height + 70;
window.open...
And it works fine. Except there seems to be a catch. When I first click on a thumb, it opens a 20x70 window and then loads the picture which is of course bigger than that, so I have to either scroll or manually resize the window.
When I click on the thumb the second time, everything is fine. Now, I understand that this is caused by the picture being stored in the temp folder somewhere after it's loaded once, so whenever I click on the thumb after that, it can get the size and display it correctly. However, when I click it the first time, the picture has not been downloaded before the window is openned, that's why the window is only 20x70.
My question is if there is any workarounds for this initial load?
Can I have some kind of a delay function to wait until the picture is downloaded to temp and then get the size and display it? Or can I resize the window after the picture is loaded? Or something else?
thanks
dima
I found the scipt on javascriptsource that shows how to do it:
...
var pic = new Image();
pic.src = (url);
var windowWidth = pic.width + 20;
var windowHeight = pic.height + 70;
window.open...
And it works fine. Except there seems to be a catch. When I first click on a thumb, it opens a 20x70 window and then loads the picture which is of course bigger than that, so I have to either scroll or manually resize the window.
When I click on the thumb the second time, everything is fine. Now, I understand that this is caused by the picture being stored in the temp folder somewhere after it's loaded once, so whenever I click on the thumb after that, it can get the size and display it correctly. However, when I click it the first time, the picture has not been downloaded before the window is openned, that's why the window is only 20x70.
My question is if there is any workarounds for this initial load?
Can I have some kind of a delay function to wait until the picture is downloaded to temp and then get the size and display it? Or can I resize the window after the picture is loaded? Or something else?
thanks
dima