(function getCloseBox (){
let target = document.body;
let MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
let mutation = new MutationObserver((mutations)=>{
mutations.forEach(function(mutation) {
console.log(mutation.type);
});
if(document.getElementById("pb_layout")){
console.log("it is found");
}else{
console.log("it is not found");
}
});
let config = { attributes: true, childList: true,subtree: true ,characterData: true}
mutation.observe(target, config);
})();
这里在if语句中我正在检查将在网站中的ajax调用之后加载的元素,但是在该网站中,此元素被加载但是变异观察者没有找到正文中的变化。仅执行else语句,此功能适用于扩展程序,因此我无法访问ajax响应。 请帮忙