导航后捕获iframe的console.log消息

我想捕获iframe导航后立即从iframe生成的日志消息。 目前我有这样的事情:

$(iframe).bind("load", null, function() { var logsToCapture = ["log", "info", "debug", "warn", "error"]; logsToCapture.forEach(function captureLogs(logType) { var original = iframe.contentWindow.console[logType]; iframe.contentWindow.console[logType] = function() { logUtil.log.apply(logUtil, arguments); original.apply(iframe.contentWindow.console, arguments); }; }); }); 

这工作正常,但它只捕获初始页面加载的消息。 我特别感兴趣的是获取加载过程中出现的消息,因为有问题的页面在启动过程中会发出大量日志。 我尝试绑定到“就绪”而不是“加载”,因为“就绪”首先触发,但之后没有捕获任何事件。