上面的脚本不能正常工作。我想将 DOMNodeInserted(Line19) 替换为 MutationObserver(line21),但是当我使用 MutationObserver 时,它不起作用。
// Line 19 (works well)
document.body.addEventListener('DOMNodeInserted', function (event) {linkifyContainer(event.target);}, false);
// Line 21 (does not work)
var observer=new window.MutationObserver(function(mutations){mutations.forEach(function(mutation){linkifyContainer(mutation.addedNodes)})});observer.observe(document.body,{childList:true,subtree:true});
第21行应该有问题,但我不知道问题是什么,我应该怎么做。
我用chrome28和firefox23检查了这个。
它是 chrome 的扩展,所以我不必使用“WebKitMutationObserver”或“MozMutationObserver”。
请告诉我解决方案。