所以IVE劫持控制台功能控制台返回undefined
var log = Function.prototype.bind.call(console.log, console);
console.log = function (a) {
log.call(console, a);
submitmsg("Log", a);
};
这有预期的效果但是它也返回“未定义”作为一个意想不到的好处
我无法弄清楚,为什么这使我觉得有东西稍微错在这里
你好由log.call(console, a)
产生世界预计
submitmsg()
是我的自定义功能
这是工作正是我想要的,正如我所说的,虽然IM略有担心,它也返回的原因,我不明白“不确定”。
注:下面的代码被张贴在OP作为一个问题的答案。关于答案的评论已转移到对这个问题的评论。
所以正确的代码应该是以下内容?
var log = Function.prototype.bind.call(console.log, console);
console.log = function (a) {
return log.call(console, a);
submitmsg("Log", a)
};
这仍然还返回 “未定义” – Fibrewire 2012-07-06 11:16:54
这是因为'log.call'返回'undefined'。这就是为什么我不确定你想要达到什么样的效果......原生的控制台。log'方法返回'undefined'。你想要返回什么? – 2012-07-06 11:18:45
对不起,我已经更详细地提交了 – Fibrewire 2012-07-06 11:29:05