theoffsetX=(document.body.scrollLeft+event.clientX)/img1.offsetWidth;
theoffsetY=(document.body.scrollTop+event.clientY)/img1.offsetHeight;
MouseAddImg.innerHTML+="<div id=Layer"+ImgID+" style=\"position:absolute; left:expression(img1.offsetWidth*"+theoffsetX+"); top:expression(img1.offsetHeight*"+theoffsetY+"); width:3px; height:3px; z-index:100; border: 1px solid #FF0000; visibility: visible; cursor:crosshair; font-size: 1pt; background-color: #FF0000;\" ></div>";
theoffsetY=(document.body.scrollTop+event.clientY)/img1.offsetHeight;
MouseAddImg.innerHTML+="<div id=Layer"+ImgID+" style=\"position:absolute; left:expression(img1.offsetWidth*"+theoffsetX+"); top:expression(img1.offsetHeight*"+theoffsetY+"); width:3px; height:3px; z-index:100; border: 1px solid #FF0000; visibility: visible; cursor:crosshair; font-size: 1pt; background-color: #FF0000;\" ></div>";
解决方案 »
- Jquery.Pagination页数刷新问题
- 请教如何用JS实现象InputFile控件那样可以弹出文件浏览窗口?
- 为什么Javascript报对象为空错误,可是对象明明存在啊,急死
- getElementsByTagName的问题
- 怎么使页面的名为price[n]input值都加起来存到别一个input?
- 字符串操作问题
- 如何安全防范站外表单提交?[高手进来讨论]
- 在线等,怎样设置<input type="text">的值?
- 如何在页面中加入Javascript中获取到服务器上的时间和本地的时间差?
- 一个有用的问题,现场给分!!!!!
- 在JSP页面里用JS来转向网页
- 如何取当前页上所有checkbox的集合?在线等待
<body bgcolor="#FFFFFF" topmargin="0" leftmargin="0">
<script language="JavaScript">
ImgID=0;
function drawboxdown(thelayer){
theoffsetX=document.body.scrollLeft+event.clientX;
theoffsetY=document.body.scrollTop+event.clientY;
MouseAddImg.innerHTML+="<div id=Layer"+ImgID+" style=\"position:absolute; left:"+theoffsetX+"px; top:"+theoffsetY+"px; width:3px; height:3px; z-index:100; border: 1px solid #FF0000; visibility: visible; cursor:crosshair; font-size: 1pt; background-color: #FF0000;\" ></div>";
ImgID++;
}
function zoomin(){
img1.style.width=(img1.clientWidth)*2;
img1.style.height=(img1.clientHeight)*2;
for(i=0;i<ImgID;i++){
nowleft=eval("Layer"+i+".style.left");
nowleft=nowleft.substring(0,nowleft.length-2)-50; //50是Layer000的left
eval("Layer"+i+".style.left=50+nowleft*2");
}
for(i=0;i<ImgID;i++){
nowtop=eval("Layer"+i+".style.top");
nowtop=nowtop.substring(0,nowtop.length-2)-50; //50是Layer000的top
eval("Layer"+i+".style.top=50+nowtop*2");
}
}
function zoomout(){
img1.style.width=(img1.clientWidth)*1/2;
img1.style.height=(img1.clientHeight)*1/2;
for(i=0;i<ImgID;i++){
nowleft=eval("Layer"+i+".style.left");
nowleft=nowleft.substring(0,nowleft.length-2)-50;
eval("Layer"+i+".style.left=50+nowleft/2");
}
for(i=0;i<ImgID;i++){
nowtop=eval("Layer"+i+".style.top");
nowtop=nowtop.substring(0,nowtop.length-2)-50;
eval("Layer"+i+".style.top=50+nowtop/2");
}
}
</script>
<span id=MouseAddImg> </span>
<div id="Layer000" style="position:absolute; width:200px; height:115px; z-index:1; overflow: visible; top: 50; left: 50;">
<img border="1" id="img1" src="http://expert.csdn.net/images/csdn.gif" style="cursor:crosshair; width:300; height:200" onclick="drawboxdown('')">
<input type="button" name="cmdAdd1" value="放大1倍" onClick="zoomin()">
<input type="button" name="cmdAdd1" value="缩小1倍" onClick="zoomout()">
</div>
</body></html>