console.logは、開発者ツールを開いてからでないと利用できません(F12で開閉を切り替えられます)。 おかしなことに、開いた後にツールを閉じても、console.logの呼び出しで投稿することができ、再びツールを開いたときにそれらが表示されます。 これはある種のバグであり、修正されるかもしれないと思っていますが、まだわかりません。
私はおそらくこのようなものを使うでしょう。
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) }
}