手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >js 加载时自动调整图片大小
js 加载时自动调整图片大小
摘要://方法:setSelectReadOnly用于设定极select控件ReadOnly,//这个一个模拟只读不是真的只读//使用了onbef...

//方法:setSelectReadOnly用于设定极select控件ReadOnly,

//这个一个模拟只读不是真的只读

//使用了onbeforeactivate,onfocus,onmouseover,onmouseout事件

//示例:<imgsrc='img.jpg'onload='ImgAutoSize(ImgD,FitWidth,FitHeight)'>;

//createbysl

//---------------------------------------------------

functionImgAutoSize(imgD,FitWidth,FitHeight)

{

varimage1=newImage();

image1.onload=function()

{

if(this.width>0&&this.height>0)

{

if(this.width/this.height>=FitWidth/FitHeight)

{

if(this.width>FitWidth)

{

imgD.width=FitWidth;

imgD.height=(this.height*FitWidth)/this.width;

}

else

{

imgD.width=this.width;

imgD.height=this.height;

}

}

else

{

if(this.height>FitHeight)

{

imgD.height=FitHeight;

imgD.width=(this.width*FitHeight)/this.height;

}

else

{

imgD.width=this.width;

imgD.height=this.height;

}

}

}

image1=null;

}

image1.src=imgD.src;

imgD.style.cursor='hand';

imgD.onclick=function(){openWin(this.src,'imgphoto',600,400)};

imgD.title="点击在新窗口中查看原图";

}

【js 加载时自动调整图片大小】相关文章:

鼠标图片振动代码

自动关闭的层

jquery实现图片左右切换的方法

jQuery预加载图片常用方法

JS实现窗口加载时模拟鼠标移动的方法

Javascript实现图片轮播效果(二)图片序列节点的控制实现

自适应图片大小的弹出窗口

nodejs修复ipa处理过的png图片

Java数据类型转换(自动转换和强制转换)

js验证上传图片的方法

精品推荐
分类导航