网页载入过程中自动调整图片的宽度,网页图片宽度自适应代码,具体代码如下:
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>网页载入过程中自动调整图片的宽度</title> </head> <body> <script language="javascript"> var flag=false; function DrawImage(ckp){ var image=new Image(); image.src=ckp.src; if(image.width>0 && image.height>0){ flag=true; if(image.width>120){ ckp.width=120; }else{ ckp.width=image.width; } ckp.alt=image.width+"×"+image.height; } } </script> <img src="http://www.phpernote.com/images/logo.gif" border="0" onload="javascript:DrawImage(this);"> </body> </html>