tags:

views:

39

answers:

5

Hi friends, i have one problem. now i dynamically create a div for displaying images based on image width and height. so how can i find image's width and height before loading images or using image src? help plz

A: 

Unfortunately, you cant know the size of an image before you load it ... (it makes sense really)

Gaby
A: 

I think you can not make it just with javascript. You need some server side script to make it possible. Can you explain your purpose for getting width and height? Actually, you can change the width and height after image loading.

xiao
please see this url:http://www.prohive.com/portfolio?pid=10.
Jeny
@Jeny, a quick IE inspector debug demonstrates that the problem is a disable() function is missed in javascript. Can you tell me where you have written the function and I can review it.
xiao
A: 

One option would be to create a server script that serves your images and change it so that it returns image size if certain parameter is passed to it. Then use ajax to call it before you load an image.

Luc
A: 

You can load the image on your page (hidden), then inspect the naturalWidth and naturalHeight properties, but I don't think this works in all browsers (I know it works in Firefox)

However it looks like this person figured out a way to use an *.htc file and IE's behavior rules to obtain the naturalWidth/naturalHeight in IE.

scunliffe
A: 

Hi friends,

u can see my project link: http://www.prohive.com/portfolio?pid=17.. here i have options for slideshow. when i click the option, i will get image height and width. firebox and chrome is working .but ie is not working(please open to ie)

Jeny