How does one write an if clause that would check to see if MutationObserver
is supported?
Mutation Observer on Android Browser is fully supported on 4.4-103, partially supported on None of the versions, and not supported on 2.3-4 Android Browser versions.
One way to watch for DOM changes in our JavaScript web app is to use the MutationObserver constructor. })(); to create the MutationObserver instance with a loop to append child elements to the body within the async function. We insert a new p element after 1 second 5 times.
The MutationObserver interface provides the ability to watch for changes being made to the DOM tree. It is designed as a replacement for the older Mutation Events feature, which was part of the DOM3 Events specification.
MutationObserver is a Web API provided by modern browsers for detecting changes in the DOM. With this API one can listen to newly added or removed nodes, attribute changes or changes in the text content of text nodes.
Try using in
operator
The in operator returns true if the specified property is in the specified object.
Syntax
prop in objectName
Parameters
prop
A string or symbol representing a property name or array index (non-symbols will be coerced to strings).
objectName
Name of an object.
if ("MutationObserver" in window) {
// do stuff
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With