0

在我的项目中,我应该识别可以通过 document.write 在脚本中完成的动态创建的标签。我为 document.write 创建了一个钩子,但它没有检索所有 document.write 函数。我的代码如下

更新:

var oldDocumentWrite = document.write; 
document.write      = function (text) 
{        
  console.log(text);
}

其中 text 是 document.write 的参数。

我将其包含在我的用户脚本中。我怎样才能得到document.write的参数。我的代码有什么错误吗?

4

1 回答 1

0

我使用下面的代码再次尝试了这个,现在我得到了所有的 document.write 方法。

 var oldDocumentWrite = document.write; 
 document.write      = function (str) 
 {        
    var elem = oldDocumentWrite.apply (document,arguments); 
    console.log("Document.write Parameters:",str);
    return elem;
 }
于 2012-05-07T09:03:10.363 回答