Connecting Tech Pros Worldwide Help | Site Map

validate image dimension in IE7

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 1st, 2007, 06:25 AM
Josee
Guest
 
Posts: n/a
Default validate image dimension in IE7

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


  #2  
Old March 1st, 2007, 10:05 AM
ASM
Guest
 
Posts: n/a
Default Re: validate image dimension in IE7

Josee a écrit :
Quote:
function validateImageDimension(path, expectedWidth, expectedHeight) {
var img = new Image();
img.onload = function () {
return ( img.width == expectedWidth &&
img.height == expectedHeight )
}
Quote:
img.src = path;
}
>
function uploadCustomerLogo() {
var customerLogoFilePath =
document.getElementById("customerLogoFile").value;
if (!validateImageDimension(customerLogoFilePath, 160,
160)) {
alert('wrong size');
return;
}


--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.