//限制在目标对象内拖动
//如果超出了边缘将目标对象的最大/最小值赋给截取层
function LimitOnTarget()
{
var oNode = document.getElementById("DIV的ID");
var oTagNode = document.getElementById("IMG的ID");
var iX = parseInt(oNode.style.left);                        //对象x坐标
var iY = parseInt(oNode.style.top);                         //对象y坐标
var iWidth = parseInt(oNode.style.width);                   //对象宽度
var iHeight = parseInt(oNode.style.height);                 //对象长度
    
var iTagX = parseInt(oTagNode.style.left);                  //目标对象x坐标
var iTagY = parseInt(oTagNode.style.top);                   //目标对象y坐标
    
var iTagWidth = parseInt(oTagNode.offsetWidth);             //目标对象宽度
var iTagHeight = parseInt(oTagNode.offsetHeight);           //目标对象长度
    
if(iX<iTagX)
{
oNode.style.left = iTagX;
}
if(iY<iTagY)
{
oNode.style.top = iTagY;
}
if(iX+iWidth>iTagX+iTagWidth)
{
oNode.style.left = iTagWidth - iWidth
}
if(iY+iHeight>iTagY+iTagHeight)
{
oNode.style.top = iTagHeight - iHeight;
}
}