So from what I can see, this answer - https://stackoverflow.com/a/54350762/479836 - would be the ideal, but unfortunately, document.elementsFromPoint()
does not work in IE11.
Failing that, the code in this answer - https://stackoverflow.com/a/22428553/479836 appears to work across most modern browsers, including IE11, but there's a bug where certain DOM elements are duplicated in the array returned by the function.
However, if anyone's looking for an document.elementsFromPoint()
shim, a good one can be found here:
https://gist.github.com/oslego/7265412
Copied here for convenience:
function elementsFromPoint(x,y) {
var elements = [], previousPointerEvents = [], current, i, d;
// get all elements via elementFromPoint, and remove them from hit-testing in order
while ((current = document.elementFromPoint(x,y)) && elements.indexOf(current)===-1 && current != null) {
// push the element and its current style
elements.push(current);
previousPointerEvents.push({
value: current.style.getPropertyValue('pointer-events'),
priority: current.style.getPropertyPriority('pointer-events')
});
// add "pointer-events: none", to get to the underlying element
current.style.setProperty('pointer-events', 'none', 'important');
}
// restore the previous pointer-events values
for(i = previousPointerEvents.length; d=previousPointerEvents[--i]; ) {
elements[i].style.setProperty('pointer-events', d.value?d.value:'', d.priority);
}
// return our results
return elements;
}