document.elementFromPoint를 사용하여 선택한 요소를 드래그하여 가져옵니다. 하지만 null을 반환합니다. 같은 코드를 실행하고 동일한 코드를 다시 실행하면 객체가 반환됩니다.document.elementFromPoint가 IE에서 null을 반환합니다.
function GetZoneFromPoint(x, y, prtDrag, elemIBeam,evnt) {
if (x == null || y == null || prtDrag == null || elemIBeam == null)
alert("Null in GetZone");
var prtDragZIndexOld = prtDrag.style.zIndex;
var elemIBeamZIndexOld = elemIBeam.style.zIndex;
prtDrag.style.zIndex = -1;
elemIBeam.style.zIndex = -1;
var zone;
zone = document.elementFromPoint(x, y);
prtDrag.style.zIndex = prtDragZIndexOld;
elemIBeam.style.zIndex = elemIBeamZIndexOld;
if (zone == null) {
zone = document.elementFromPoint(x, y);
if (zone == null) {
debugger;
zone = event.rangeParent;
}
}
if (zone == null) {
alert('null');
return null;
}
if (x < 0 || x > document.body.clientWidth ||
y < 0 || y > document.body.clientHeight) {
zone = null;
}
else if ((zone.className == 'LayoutWellElement') ||
(zone.className == 'LayoutMainElement') ||
(zone.className == 'ElementFrame')) {
while ((!FIsZone(zone)) && (zone.tagName != 'BODY')) {
zone = zone.parentElement;
}
}
if (!FIsZone(zone)) {
zone = null;
}
return zone;
}