zhihuiweb
02-15-2006, 02:12 AM
i have some pictures in a page. there are have difference sizes. some
of them are too widen for be arrange in a line. so
i been tried to adject their sizes to more suitable.
i add a event to that image likes:
<img id="img" onLoad="adjustSize(this)" src="123.jpg">
and write a function in javascript:
function adjustSize(obj){
if (obj.width>250){
sizeRate=250/obj.width;
obj.width=obj.width*sizeRate;
if (obj.hight>268)
obj.hight=268;
}
}
but exactly,i can get the image's width and height. cuz the loading
hasn't finished while the function of adjustSize works.
In addition,those picture were loaded from a database.
so first i can't exactly get the sizse when a bigger picture is
loading.
thus in the event of picture loading the function isn't works cuz it
keeping a wrong sizes as zero.
but the event 'onMouseOver' works well.cuz it cant get the size exactly
after they were completely loaded
can anyone tell me how to deal this?
Tks advanced.
of them are too widen for be arrange in a line. so
i been tried to adject their sizes to more suitable.
i add a event to that image likes:
<img id="img" onLoad="adjustSize(this)" src="123.jpg">
and write a function in javascript:
function adjustSize(obj){
if (obj.width>250){
sizeRate=250/obj.width;
obj.width=obj.width*sizeRate;
if (obj.hight>268)
obj.hight=268;
}
}
but exactly,i can get the image's width and height. cuz the loading
hasn't finished while the function of adjustSize works.
In addition,those picture were loaded from a database.
so first i can't exactly get the sizse when a bigger picture is
loading.
thus in the event of picture loading the function isn't works cuz it
keeping a wrong sizes as zero.
but the event 'onMouseOver' works well.cuz it cant get the size exactly
after they were completely loaded
can anyone tell me how to deal this?
Tks advanced.