<div class="htmlarea"> <textarea id="runcode59862"> <title>emu</title> 原图: <img src="http://www.web745.com/image/logo.gif" style="max-width:90%" style="max-width:90%" id="srcImg" onmousemove="zoom()" alt="用javascript制作放大镜放大图片_图象特效" > 局部放大图: <div style="overflow:hidden"><img id="zoomImg" alt="用javascript制作放大镜放大图片_图象特效" ></div> <script language="JavaScript"> <!-- zoomImg.src = srcImg.src; srcImg.height = srcImg.height/2; var zoomRate = 5; //放大倍数 zoomImg.height = srcImg.height*zoomRate; zoomImg.parentNode.style.width = srcImg.width; zoomImg.parentNode.style.height = srcImg.height; function zoom(){ var elm = event.srcElement; h = elm.offsetHeight/zoomRate/2; w = elm.offsetWidth/zoomRate/2; var x = event.x-elm.offsetLeft; x=x<(elm.offsetWidth-w)?x<w?w:x:elm.offsetWidth-w; zoomImg.style.marginLeft=(w-x)*zoomRate; var y = event.y-elm.offsetTop; y=y<(elm.offsetHeight-h)?y<h?h:y:elm.offsetHeight-h; zoomImg.style.marginTop=(h-y)*zoomRate; } //--> </script> </textarea><br><input onclick="runEx('runcode59862')" type="button" value="运行代码"> <input onclick="doCopy('runcode59862')" type="button" value="复制代码"> <input onclick="doSave(runcode59862)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>