BinodSuman 2 Newbie Poster

I was searching a solution to get height and widht of an image using javascript. I got many but all those solution only worked when image present in browser cache.

Finally I got one solution to get image height and width even image does not exist in browser cache. Just I want to share all of you.

<script type="text/javascript" language="javascript1.2">

var imgHeight;
var imgWidth;

function findHHandWW() {
imgHeight = this.width;imgWidth = this.width;return true;
}

function showImage(imgPath) {
var myImage = new Image();
myImage.name = imgPath;
myImage.onload = findHHandWW;
myImage.src = imgPath;
}
</script>

Thanks,

Binod Suman

<URL SNIPPED>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.