js 加载时自动调整图片大小_Javascript教程-查字典教程网
js 加载时自动调整图片大小
js 加载时自动调整图片大小
发布时间:2016-12-30 来源:查字典编辑
摘要://方法: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="点击在新窗口中查看原图";

}

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Javascript教程学习
    热门Javascript教程学习
    编程开发子分类