web放大镜改进版本
<script language="javascript" type="text/javascript">
var iDivHeight = 100;
var iDivWidth = 100;
var iMultiple =1;
function show(src, sFileName)
{
if ((event.button == 1) && (event.ctrlKey == true))
iMultiple -= 1;
else
if (event.button == 1)
iMultiple += 1;
if (iMultiple < 2) iMultiple = 2;
if (iMultiple > 14) iMultiple = 14;
var iPosX, iPosY;
var iMouseX = event.offsetX;
var iMouseY = event.offsetY;
var iBigImgWidth = src.clientWidth * iMultiple;
var iBigImgHeight = src.clientHeight * iMultiple;
if (iBigImgWidth <= iDivWidth)
{
iPosX = (iDivWidth - iBigImgWidth) / 2;
}
else
{
if ((iMouseX * iMultiple) <= (iDivWidth / 2))
{
iPosX = 0;
}
else
{
if (((src.clientWidth - iMouseX) * iMultiple) <= (iDivWidth / 2))
{
iPosX = -(iBigImgWidth - iDivWidth);
}
else
{
iPosX = -(iMouseX * iMultiple - iDivWidth / 2);
}
}
}
if (iBigImgHeight <= iDivHeight)
{
iPosY = (iDivHeight - iBigImgHeight) / 2;
}
else
{
if ((iMouseY * iMultiple) <= (iDivHeight / 2))
{
iPosY = 0;
}
else
{
if (((src.clientHeight - iMouseY) * iMultiple) <= (iDivHeight / 2))
{
iPosY = -(iBigImgHeight - iDivHeight);
}
else
{
iPosY = -(iMouseY * iMultiple - iDivHeight / 2);
}
}
}
div1.style.height = iDivHeight;
div1.style.width = iDivWidth;
div1.style.top=event.clientY;
div1.style.left=event.clientX;
div1.innerHTML = "<img id='BigImg'" + "src='" + sFileName + "'" + " style='position:relative; width:" + iBigImgWidth + "; height:" + iBigImgHeight + "; top:" + iPosY + "; left:" + iPosX +";'/>";
</script>