核心提示:淘宝放大镜代码实例!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD...
淘宝放大镜代码实例
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>放大镜</title>
<link rel="stylesheet" type="text/css" href="style/css.css">
</head>
<script type="text/javascript">
</script>
<body>
<p id="p1">
<p class="small_pic">
<span class="mark"></span>
<span class="float_layer"></span>
<img src="images/b.jpg" alt="" longdesc="" />
</p>
<p class="big_pic">
<img src="images/a.jpg" alt=""longdesc="" />
</p>
</p>
</body>
<script src="./js/js.js"></script>
</html>
function getByClass(oParent,sClass){
var aEle=oParent.getElementsByTagName('*');
var aTmp=[];
var i=0;
for(i=0;iseout="function(){" omark.onmouseover="function(){" osm="getByClass(oDiv,'small_pic')[0];" return="" t="disY;" var="">(oMark.offsetWidth-oFloat.offsetWidth)?l=oMark.offsetWidth-oFloat.offsetWidth:l=disX;
t<0?t=0:t>(oMark.offsetWidth-oFloat.offsetHeight)?t=oMark.offsetWidth-oFloat.offsetHeight:t=disY;
// if(l<0){
// l=0;
// }else if(l>oMark.offsetWidth-oFloat.offsetWidth){
// l=oMark.offsetWidth-oFloat.offsetWidth;
// }
// if(t<0){
// t=0;
// }else if(t>oMark.offsetWidth-oFloat.offsetHeight){
// t=oMark.offsetWidth-oFloat.offsetHeight;
// }
oFloat.style.left=l+'px';
oFloat.style.top=t+'px';
var percentX=l/(oMark.offsetWidth-oFloat.offsetWidth);
var percentY=t/(oMark.offsetHeight-oFloat.offsetHeight);
oImg.style.left=-(oImg.offsetWidth-oBg.offsetWidth)*percentX +'px';
oImg.style.top=-(oImg.offsetHeight-oBg.offsetHeight)*percentY +'px';
}


