|
// 這個(gè)一個(gè)模擬只讀不是真的只讀
// 使用了onbeforeactivate,onfocus,onmouseover,onmouseout事件
// 示例:< img src='img.jpg' onload='ImgAutoSize(ImgD,FitWidth,FitHeight)' > ;
// create by sl
// ---------------------------------------------------
function ImgAutoSize(imgD,FitWidth,FitHeight)
{
var image1=new Image();
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 = "點(diǎn)擊在新窗口中查看原圖";
}
JavaScript技術(shù):js 加載時(shí)自動(dòng)調(diào)整圖片大小,轉(zhuǎn)載需保留來源!
鄭重聲明:本文版權(quán)歸原作者所有,轉(zhuǎn)載文章僅為傳播更多信息之目的,如作者信息標(biāo)記有誤,請第一時(shí)間聯(lián)系我們修改或刪除,多謝。