The compareDocumentPosition method is not supported only in IE9

On one of my web pages, I use the following JavaScript line:

return !!(a.compareDocumentPosition(b) & 16); 

However, only in IE9, I get the following error:

The object does not support the property or method 'compareDocumentPosition'

Other browsers work fine. Does anyone know of available fixes or workarounds for this?

+4
source share
1 answer

Internet Explorer only supports compareDocumentPosition in IE9 mode. Make sure you have at the beginning of the markup and document.documentMode returns 9

+1
source

All Articles