Popup window with the same size as an image

I tried to write a script that, when the user click on a thumbnail image, it will popup a new window with the same size as the enlarged picture, and this is what I did:
var itemImg = new Image();
var win_width = 100;
var win_height = 100;
function PopupPhoto(img, name) {
itemImg.src = img;
win_width = itemImg.width + 20;
win_height = itemImg.height + 20;
var hWnd = window.open(img,name,"width="+win_width + ",height=" +win_height+",scrollbars=no");

What happened was that whenever I click the thumbnail image (the first time), it will popup a small window with weird small size and the "enlarged version" of the picture has also strunk for no reason. This problem does not persist when i click the thumbnail the second time though. Anything wrong with the script?
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!