Javascript 记录每个文档

Javascript 记录每个文档,javascript,jquery,Javascript,Jquery,每次出现document.write()时,是否有办法控制台.log() 类似这样的东西(似乎不起作用): 可能不是最好的方法,但您可以重新定义文档。编写 document.__write = document.write; // copy the original definition // redefine document.write = function(contents) { console.log(contents); // log document

每次出现
document.write()
时,是否有办法
控制台.log()

类似这样的东西(似乎不起作用):


可能不是最好的方法,但您可以重新定义
文档。编写

document.__write = document.write; // copy the original definition

// redefine
document.write = function(contents) {      
  console.log(contents); // log      
  document.__write(contents); // call the original
}

PS-要监视DOM的更改,您应该使用更健壮的方法,例如

可能不是最好的方法,但是您可以重新定义
文档。编写

document.__write = document.write; // copy the original definition

// redefine
document.write = function(contents) {      
  console.log(contents); // log      
  document.__write(contents); // call the original
}

PS-为了监视DOM的更改,您应该使用更强大的工具,例如

,出于好奇,为什么要使用document.write?我没有。我想知道什么时候有东西被添加到dom中。你建议用什么来代替登录?出于好奇,你为什么要使用文档。写?我不是。我想知道什么时候有东西被添加到dom中。你建议改为登录什么?谢谢xbonez-突变事件看起来正是我想要的。谢谢xbonez-突变事件看起来正是我想要的。