validate image dimension in IE7

J

Josee

function validateImageDimension(path, expectedWidth, expectedHeight) {
var img = new Image();
img.src = path;
return (img.width == expectedWidth && img.height ==
expectedHeight);
}

function uploadCustomerLogo() {
var customerLogoFilePath =
document.getElementById("customerLogoFile").value;
if (!validateImageDimension(customerLogoFilePath, 160,
160)) {
alert('wrong size');
return;
}

I have this javascript to validate image dimension before uploading.
It was working fine in IE6. But it doesn't work anymore in IE7.
Because the image width and height is return as 0.

Anyone has idea how to fix this? Or a better way to do this?

Thanks
 
A

ASM

Josee a écrit :
function validateImageDimension(path, expectedWidth, expectedHeight) {
var img = new Image();

img.onload = function () {
return ( img.width == expectedWidth &&
img.height == expectedHeight )
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top