![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
function isMouseInBox(obj)
{
var oEvent = event || window.event;
var point1 = new Array(event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop);
var point2 = getObjPosition(obj);
return ((point1[0] >= point2[0]) && point1[1] >= point2[1]
&& point1[0] - point2[0] <= obj.offsetWidth
&& point1[1] - point2[1] <= obj.offsetHeight);
}
function getObjPosition(obj)
{
var point = new Array(0,0);
while (obj != document.body)
{
point[0] += obj.offsetLeft;
point[1] += obj.offsetTop;
obj = obj.offsetParent;
}
return point;
}
{
var oEvent = event || window.event;
var point1 = new Array(event.clientX + document.body.scrollLeft, event.clientY + document.body.scrollTop);
var point2 = getObjPosition(obj);
return ((point1[0] >= point2[0]) && point1[1] >= point2[1]
&& point1[0] - point2[0] <= obj.offsetWidth
&& point1[1] - point2[1] <= obj.offsetHeight);
}
function getObjPosition(obj)
{
var point = new Array(0,0);
while (obj != document.body)
{
point[0] += obj.offsetLeft;
point[1] += obj.offsetTop;
obj = obj.offsetParent;
}
return point;
}