Javascript 修改firebugx.js以适应IE开发者工具
该文件(如下所示)同时检查这两个选项!窗口。控制台和!console.firebug,可正确检测是否安装了firebug。但是,该检查不适用于IE开发者工具中的本机控制台对象——它覆盖了IE控制台对象 例如,如果我包含firebugx.js代码,那么以下异常将不会出现在IE控制台中(它将被吞没): 问题:适应IE开发者调试器的最佳方法是什么?也许显而易见的答案是在IE中调试时简单地注释掉firebugx.js检查。还有其他方法吗 参考资料:Javascript 修改firebugx.js以适应IE开发者工具,javascript,internet-explorer,firebug,Javascript,Internet Explorer,Firebug,该文件(如下所示)同时检查这两个选项!窗口。控制台和!console.firebug,可正确检测是否安装了firebug。但是,该检查不适用于IE开发者工具中的本机控制台对象——它覆盖了IE控制台对象 例如,如果我包含firebugx.js代码,那么以下异常将不会出现在IE控制台中(它将被吞没): 问题:适应IE开发者调试器的最佳方法是什么?也许显而易见的答案是在IE中调试时简单地注释掉firebugx.js检查。还有其他方法吗 参考资料: 如果(!window.console | |!con
如果(!window.console | |!console.firebug)
{
变量名称=[“日志”、“调试”、“信息”、“警告”、“错误”、“断言”、“目录”、“dirxml”,
“组”、“组结束”、“时间”、“时间结束”、“计数”、“跟踪”、“配置文件”、“配置文件结束”];
window.console={};
对于(变量i=0;i
我想下面对firebugx.js的修改可以解决这个问题。我仅在window.console不存在时重新定义它,然后可以选择在window.console上定义缺少的函数。我对修改firebugx.js犹豫不决,但我真的看不出这有什么坏处。这是在Firefox和IE调试器之间快速切换的最简单方法
firebugxCustom.js
if (!window.console) {
window.console = {};
}
if (!window.console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
for (var i = 0; i < names.length; ++i) {
if (!window.console[names[i]]) {
window.console[names[i]] = function () { }
}
}
}
if(!window.console){
window.console={};
}
如果(!window.console.firebug){
变量名称=[“日志”、“调试”、“信息”、“警告”、“错误”、“断言”、“目录”、“dirxml”,
“组”、“组结束”、“时间”、“时间结束”、“计数”、“跟踪”、“配置文件”、“配置文件结束”];
对于(变量i=0;i
if (!window.console || !console.firebug)
{
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() {}
}
if (!window.console) {
window.console = {};
}
if (!window.console.firebug) {
var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
"group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
for (var i = 0; i < names.length; ++i) {
if (!window.console[names[i]]) {
window.console[names[i]] = function () { }
}
}
}