【发布时间】:2020-12-16 16:23:16
【问题描述】:
我正在尝试捕获一个 iframe 的控制台日志,我无权访问它的源代码和实现。
<iframe src="an http address" name="my-iframe" allowFullScreen/>
当 iframe 记录数据时,我会在控制台中看到它们。但问题是,
这段代码
// define a new console
var console = (function(oldCons){
return {
log: function(text){
oldCons.log(text);
if(text === "hi"){
alert("text")
}
},
info: function (text) {
oldCons.info(text);
if(text === "hi"){
alert("text")
}
},
warn: function (text) {
oldCons.warn(text);
if(text === "hi"){
alert("text")
}
},
error: function (text) {
oldCons.error(text);
if(text === "hi"){
alert("text")
}
}
};
}(window.console));
//Then redefine the old console
window.console = console;
我从this post 获得的内容不适用于 iframe 日志。 它只适用于我的应用控制台日志。
【问题讨论】:
标签: javascript