html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">JavaScript点小图弹出放大图片的代码 - www.webdm.cn*{margin:0;padding:0;}img{border:0;border:1px #ccc solid;}body{font-size:12px;background:#fff;}a{color:#333;text-decoration:none;}a:hover{text-decoration:none;}.main{position:relative;width:640px;margin:20px auto;}.left{float:left;width:220px;}/*www.webdm.cn*/.left li{float:left;margin-right:8px;list-style:none;}.right{float:right;width:400px;}.right a{float:left;margin-right:10px;padding:5px 10px;}.right a:hover{background:#ff9000;color:#fff;}.left a:hover{position:relative;top:1px;left:1px;}#imglink{float:none;margin:0;padding:0;}#links,#more{margin-top:400px;}.fxImg{position:absolute;left:0;top:0;background:#fff;display:none;cursor:pointer;padding:5px;}ldh={
$:function(o){returntypeofo=="string"?document.getElementById(o):o},
$$:function(o,p){return(p==undefined?document:this.$(p)).getElementsByTagName(o)},
on:function(o,type,fn){o.attachEvent?o.attachEvent('on'+type,function(){fn.call(o)}):o.addEventListener(type,fn,false);returnthis},
css:function(who,key){if(who.style[key]!='')returnwho.style[key];if(!!window.ActiveXObject)returnwho.currentStyle[key];returndocument.defaultView.getComputedStyle(who,"")
.getPropertyValue(key.replace(/([A-Z])/g,"-$1").toLowerCase());
},
pos:function(who){varp=ldh.$(who),x=0,y=0;while(p&&!(/html|body/i.test(p.tagName))){x+=p.offsetLeft;y+=p.offsetTop;p=p.offsetParent;};return{'x':x,'y':y};
},
move:function(who,attr,val,s,fn){
who=this.$(who);varisbg=/backgroundPosition/i.test(attr)
,fm=parseInt(this.css(who,attr))||0,by=isbg?((who.getAttribute('bg_y')||0)+'px'):'';if(this.css(who,attr)==undefined&&isbg)fm=200;variFx=this.fx(fm,val,s);
clearInterval(who['timer_'+attr]);
who['timer_'+attr]=setInterval(function(){varv=iFx();
who.style[attr]=v+'px'+by;if(v==val){ fn&&fn();clearInterval(who['timer_'+attr]);};
},18);returnthis;
},
fx:function(form,to,s){varm=Math[form
}
};
ldh.on(window,'load',function(){varfxImg=document.createElement('IMG');
fxImg.className='fxImg';
document.body.appendChild(fxImg);varpos=ldh.pos('preview');varlinks=ldh.$$('A',ldh.$('menuPic'));for(vari=0;i
,attr={href:'javascript:void(0);',imgsrc:$p.src,x:mypos.x,y:mypos.y,'url':url};for(varIdinattr){$[Id]=attr[Id]}
ldh.on($,'click',function(){
fxImg.src=this.imgsrc;var$$=fxImg.style,This=this;
$$.left=this.x+'px';
$$.top=this.y+'px';
$$.display='block';
$$.height='140px';
fxImg.οnclick=function(){location=This.url};
ldh.move(fxImg,'left',pos.x).move(fxImg,'top',pos.y,0.4,function(){ldh.move(fxImg,'height',400)});
});
}
})