是否可以通过编程方式访问以前记录的Firebug输出?
例如:
console.log('a');
console.log('b');
console.log('c');
for (var i = 0; i < console.output.length; ++i) {
alert(console.output[i]); // "a", "b", "c"
}
Run Code Online (Sandbox Code Playgroud) 我有几个相互依赖的脚本块.我需要在一个范围内执行它们.
我的尝试:
var scopeWrapper = {};
with(scopeWrapper) {
(function() {
this.run = function(code) {
eval(code);
};
}).call(scopeWrapper);
}
scopeWrapper.run('function test() { alert("passed"); }');
scopeWrapper.run('test();');
Run Code Online (Sandbox Code Playgroud)
我得到'测试未定义'错误.似乎代码在不同的范围内执行.为什么会这样?