Click to See Complete Forum and Search --> : Pop Up


elektroman
June 7th, 2005, 09:13 AM
I have a link to an image I open in a pop up window using this javascript function below to resize the popup window according to the dimensions of the image:

function enlarge(image)
{
var i = new Image();
i.src = image;
var x = i.width;
var y = i.height;
x+=40;
y+=40;
// window.status for degugging:
window.status = image + " = " + x + " x " + y + " pixels";
var z = "scrollbars=yes,resizable=yes,,status=no,location=no,toolbar=no,width=" + (x) + ",height=" + (y);
win=window.open(image,"image",z);
}


The first time I click on the link the function doesn't manage to get the width and the height of the image

How can i solve this problem? :cry:

thanks in advance

Dr. Script
June 7th, 2005, 03:48 PM
Umm, not sure of the error, but you could do something to help out debugging. Throw the code into a try..catch block (the x and y part):try {
var x = i.width;
var y = i.height;
}
catch(e) {
// e is the error object. You can alert the message or other stuff here.
alert(e.message);
}Find out what alerts from this code. If nothing alerts, the issue would deal with the window buffer, which is involved in all languages, but I won't confuse with with all that.