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

Javascript 导航后捕获iframe的console.log消息,javascript,jquery,iframe,logging,Javascript,Jquery,Iframe,Logging,我想捕获iframe导航后立即从iframe生成的日志消息。目前我有这样的想法: $(iframe).bind("load", null, function() { var logsToCapture = ["log", "info", "debug", "warn", "error"]; logsToCapture.forEach(function captureLogs(logType) { var original = iframe.contentWindo

我想捕获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);
        };
    });
});
这很好,但它只在初始页面加载后捕获消息。我特别感兴趣的是获取加载期间发生的消息,因为所讨论的页面在启动期间会发出大量日志。我尝试绑定到“ready”而不是“load”,因为“ready”首先触发,但随后没有捕获任何事件