Wrox Programmer Forums
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 4th, 2009, 01:49 PM
Registered User
 
Join Date: Jun 2009
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to get width and height of an image in javascript

I got many ways to get height and width of an image, but all methods only work when image are in cache. But finally I got solution to get image height and width even image does not present in cache.

<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

http://binodsuman.blogspot.com/2009/...-of-image.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 2: width/height mcleod BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 5 May 24th, 2007 09:55 PM
get the height and width of an image with js crmpicco Javascript How-To 1 August 30th, 2006 11:26 PM
how can I get width/height of a picture? keyvanjan Classic ASP Basics 2 May 29th, 2006 07:29 AM
Finding Image width and height AlDugan XSLT 1 March 29th, 2006 05:37 PM
Height and Width? venkatesh_anmca Beginning VB 6 0 January 31st, 2005 05:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.