Restoring console.log()
For some reason, the prototype framework (or another JavaScript code) that is shipped with Magento is replacing standard console functions, so I can't debug anything. Writing down in JavaScript console console
I get the following output:
> console
Object
assert: function () {}
count: function () {}
debug: function () {}
dir: function () {}
dirxml: function () {}
error: function () {}
group: function () {}
groupEnd: function () {}
info: function () {}
log: function () {}
profile: function () {}
profileEnd: function () {}
time: function () {}
timeEnd: function () {}
trace: function () {}
warn: function () {}
I'm using Google Chrome version 13.0.782.112
on Linux.
Prototype JavaScript framework, version 1.6.0.3
Is there a quick way to solve this?
For example,
delete console.log
would also restore console.log
:
console.log = null;
console.log; // null
delete console.log;
console.log; // function log() { [native code] }
Since original console is in window.console object, try restoring window.console
from iframe
:
var i = document.createElement('iframe');
i.style.display = 'none';
document.body.appendChild(i);
window.console = i.contentWindow.console;
i.parentNode.removeChild(i);
Works for me on Chrome 14.
Magento在/js/varien/js.js
有以下代码 - 将它注释掉并且可以使用。
if (!("console" in window) || !("firebug" in console))
{
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
window.console = {};
for (var i = 0; i < names.length; ++i)
window.console[names[i]] = function() {}
}
链接地址: http://www.djcxy.com/p/52660.html
上一篇: 开发者命令提示VS2013在哪里?
下一篇: 恢复console.log()