根据本帖,测试版中有,但发布版中没有?
console.log 只有在打开 "开发工具"(F12 用于切换打开和关闭)后才可用。 有趣的是,在你打开它之后,你可以关闭它,然后仍然通过调用 console.log 向它发帖,当你重新打开它时就会看到这些帖子。 我想这可能是个 Bug,可能会被修复,但我们拭目以待。
我可能会用这样的方法:
function trace(s) { if ('console' in self && 'log' in console) console.log(s) // the line below you might want to comment out, so it dies silent // but nice for seeing when the console is available or not. else alert(s) }
甚至更简单:
function trace(s) { try { console.log(s) } catch (e) { alert(s) } }
值得注意的是,IE8 中的 console.log 并非真正的 Javascript 函数。它不支持 apply 或 call 方法。
console.log
apply
call
它可以在 IE8 中运行。点击 F12,打开 IE8's 开发工具。
>>console.log('test') LOG: test
console.log 只有在打开 "开发工具"(F12 用于切换打开和关闭)后才可用。 有趣的是,在你打开它之后,你可以关闭它,然后仍然通过调用 console.log 向它发帖,当你重新打开它时就会看到这些帖子。 我想这可能是个 Bug,可能会被修复,但我们拭目以待。
我可能会用这样的方法:
甚至更简单:
值得注意的是,IE8 中的
console.log
并非真正的 Javascript 函数。它不支持apply
或call
方法。它可以在 IE8 中运行。点击 F12,打开 IE8's 开发工具。