console.log 报错 uncaught typeerror illegal invocation

 

因为ie不支持console.log的原因 封装了一层 代码如下

function debug(){

  window.console && console.log.apply(null , arguments);
}

FF下正常 chrome下把错uncaught typeerror illegal invocation

原因是console.log的运行上下文要求是console不能是其它任何别的object

 

console.info.call(this,"stuff")
TypeError:Illegal invocation
console
.info.call(console,"stuff")
stuff



修改代码为
window.console && console.log.apply(console , arguments);


posted on 2012-06-18 12:22  雨弓  阅读(2325)  评论(0编辑  收藏  举报