01 | < html > |
02 | < head > |
03 | < meta http-equiv = "Content-Type" content = "text/html; charset=utf-8" /> |
04 | < title >网页载入过程中自动调整图片的宽度</ title > |
05 | </ head > |
06 |
07 | < body > |
08 | < script language = "javascript" > |
09 | var flag=false; |
10 | function DrawImage(ckp){ |
11 | var image=new Image(); |
12 | image.src=ckp.src; |
13 | if(image.width>0 && image.height>0){ |
14 | flag=true; |
15 | if(image.width>120){ |
16 | ckp.width=120; |
17 | }else{ |
18 | ckp.width=image.width; |
19 | } |
20 | ckp.alt=image.width+"×"+image.height; |
21 | } |
22 | } |
23 | </ script > |
24 |
25 | < img src = "http://www.phpernote.com/images/logo.gif" border = "0" onload = "javascript:DrawImage(this);" > |
26 | </ body > |
27 | </ html > |