Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
-6
rated 0 times [  0] [ 6]  / answers: 1 / hits: 14107  / 11 Years ago, wed, december 4, 2013, 12:00:00

I am attempting to fix and issue with my code. I was originally using DOMNodeRemoved and DOMNodeInserted for keeping an eye on an element within a page I am working on. They worked well but did not function in IE. So I started trying to work with a MutationObserver.



Here is my Code it's called on onPageInit(the callback writes to the console but I disabled it since IE no longer supports console):



var callback = function(allmutations){
allmutations.map( function(mr){
var mt = 'Mutation type: ' + mr.type; // log the type of mutation
mt += 'Mutation target: ' + mr.target; // log the node affected.
//console.log( mt );
})
}
mo = new MutationObserver(callback),
options = {
// required, and observes additions or deletion of child nodes.
'childList': true,
// observes the addition or deletion of grandchild nodes.
'subtree': true
}
alert('its alive');
mo.observe(document.body, options);


It works fine in chrome, however for some reason falls flat in IE. I get a message box during load of the page that says :



An unexpected error occurred in a script running on this page.
onPageInit(pageInit)
scriptname

JS_EXCEPTION
TypeError 'MutationObserver' is undefined


Am I doing something wrong?
Additional info:
Page is a netsuite page, running jQuery 1.7.2 (if it matters)


More From » jquery

 Answers
9

That method was added in IE11, therefore it won't be available if the browser is running in compatibility mode for anything other than IE11.



http://msdn.microsoft.com/en-us/library/ie/dn265034(v=vs.85).aspx


[#49846] Wednesday, December 4, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parkernotnamedt

Total Points: 539
Total Questions: 90
Total Answers: 99

Location: Hong Kong
Member since Tue, Oct 19, 2021
3 Years ago
;