473,323 Members | 1,547 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,323 software developers and data experts.

how to dynamic control some picture's size by Javascript

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.

can somebody tell me how to deal this.
Tks advanced.

Feb 14 '06 #1
5 1232
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.

Feb 15 '06 #2
You could move the onLoad to the body tag, does that work?

Feb 15 '06 #3
On 14 Feb 2006 16:51:16 -0800, in comp.lang.javascript
bl********@gmail.com
<11**********************@g47g2000cwa.googlegroups .com> wrote:
| 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.


There are 2 options.
1. when storing the images to the database get the image dimension and
save them also.

2. since you are using server-side scripting you could use:
http://www.4guysfromrolla.com/webtec...imgsz.asp.html
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Feb 15 '06 #4
to mouseit101: TKS for your advice,but put that code in body tag got
the same result.

to Jeff: TKS a lot,you have been your wonderful help.
i would choose the second way,since i had uploaded so many pictures to
my webspace.
Thanks for your wonderful code, it help me.

Feb 15 '06 #5
On 14 Feb 2006 18:49:18 -0800, in comp.lang.javascript
bl********@gmail.com
<11**********************@g14g2000cwa.googlegroups .com> wrote:
| to mouseit101: TKS for your advice,but put that code in body tag got
| the same result.
|
| to Jeff: TKS a lot,you have been your wonderful help.
| i would choose the second way,since i had uploaded so many pictures to
| my webspace.
| Thanks for your wonderful code, it help me.


No probs but I must point out that I'm not the author of the code :-)
---------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
---------------------------------------------------------------
Feb 15 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: pizzy | last post by:
INTRO: I tried to clean it up for easy reading. I hope I didn't make any mistakes. PROBLEM: WOW, this is some crazy sh!t. I can't get my checkbox (see "TAGSELECTED") to print my textboxes (see...
3
by: Robert Mark Bram | last post by:
Hi All! Has anyone seen an example of the following javascript powered control: - a dropdown select menu - the width of the control is set. Assume by "control" I mean the visible part of the...
3
by: coolsti | last post by:
I need some help here. I am making an application which allows a user to look at a series of picture files one at a time, and enter the outcome of various visual tests to a database. The...
1
by: tribal boy | last post by:
Guys, I am using a dynamic menu which uses xml,xsl a css file and javascript. This works fine when there are no server controls around or underneath it. The problem is whenever the menu...
0
by: Workgroups | last post by:
Not sure the best way to go about making this: I have 3 user defineable values - Width, Height, and Size. These values need to define a "grid" of some kind in the following manner: The Width is...
6
by: Rich | last post by:
Hello, I want to simulate the dynamic thumbnail display of Windows Explorer (winxp) on a form or pannel container. If I place a picture box on my container form/pannel and dimension it to the...
1
by: Satish.Talyan | last post by:
hi, i want to create a dynamic tree hierarchy in javascript.there are two parts in tree, group & user.when we click on group then users come under that's tree category will be opened.problem is...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
1
oranoos3000
by: oranoos3000 | last post by:
hi would you please help me i have a online shopping center that i show pictures of the my product in home page. in the InterExplorer pictures is shown correctly but in Firefox browser is shown...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.